Posts Tagged With: SourceTree

Copying property definitions for custom controls in #XPages

PropertyDefinitionSometimes, when I’m working on my applications, I’ll decide that I want to copy a property definition from one custom control to another. When using the standard properties interface, it’s a lot of work. You have to put the right information into the right fields and switch between tabs. It’s a real bother.

Interestingly, it never occurred to me to look at the .xsp-config documents until we started using SourceTree for source control.* I was looking at some changes and suddenly noticed that … the property definitions are right there! So, instead of slogging through manual editing of the definitions in the UI in Designer, I could just go to either the Navigator or the Package Explorer Eclipse view to open and edit the properties as simple XML.

    <property>
      <property-name>deletionAllowed</property-name>
      <property-class>boolean</property-class>
      <display-name>Allow deletions of attachments</display-name>
      <property-extension>
        <designer-extension>
          <category>Control information</category>
          <editor>com.ibm.std.Boolean</editor>
          <default-value>false</default-value>
        </designer-extension>
        <required>false</required>
      </property-extension>
      <description>Determines if attachments may be deleted,
Deletions are soft and may be recovered within recovery period.
(default: false)</description>
    </property>

So, if I realized that I needed that property on a different custom control, or I wanted to create a second property on the same control with a different name, I could simply copy-paste the code and edit it as necessary.

There is one pretty cool PropertyCategoriespiece of the property definition that seems only to be available when you edit the code directly. That’s the category definition. If you provide a category definition as shown in my code snippet above, then when you’re setting the properties of the custom control that you’ve inserted, it displays categorized properties as part of that category in the UI for ‘All Properties’. I urge you to make sure that if you do fiddle with the properties on the back-end this way, that you first give yourself examples by doing most of it using the UI for adding properties. As with anything else I do in XPages, I find myself wanting to get right to the code, not to use the UI provided by Designer.

It’s interesting that it actually does give you an option that you don’t seem to be able to get otherwise.

* I want to thank PSC for getting us to use SourceTree and bitbucket (while Kathy and Brad do some work for us) and to Paul Withers for his excellent Notes in 9 video on how to do it (for our internal ones).

Categories: Xpages | Tags: , , , , | Leave a comment

Blog at WordPress.com.

%d bloggers like this: