Setting property definition properties for custom controls
Define your own properties for the custom control. You can specify default editors and values to use when setting properties for custom controls inside XPages. You can also write scripts that determine when properties are visible and considered valid inside XPages.
Before you begin
About this task
For example, the following two scenarios describe situations in which developers may want to define their own properties and values:
Scenario 1
You are working with a custom control that contains a label. You want to be able to bind a value to the label and allow the label to vary for each use on an XPage or custom control. To do this, you take the following steps:
- Select the custom control in the XPages editor.
- In the Properties view, click the Property Definition tab.
- Click New Property.
- Type name in the Name field, and specify
string
as the property type.- Add a label to the custom control.
- Click
to save your changes.- Create an XPage and add the custom control to it.
- Select the custom control in the XPage.
- In the Properties view, click the All Properties tab.
- In the other category, find the property called
name
.- In the Value field, type country.
- Click
to save your changes.Scenario 2
You are working with a custom control that displays the days of the week. You want to define a property that determines if the weekdays should display in a combo box or a list box. To do this, you take the following steps:
- Select the custom control in the XPages editor.
- In the Properties view, click the Property Definition tab.
- Click New Property.
- Type display in the Name field, and specify
string
as the property type.- Add both a combo box and a radio button to the custom control.
- In the XPages editor, select the combo box.
- In the Properties view, click the Combo Box tab.
- With Visible selected (the default), click the computed property menu button.
- Select Compute value.
- In the script editor, select EL as the scripting language.
- Select Compute on Page Load.
- In the field, type this formula: return "combo" == compositeData.get("display");.
- Click OK to close the script editor.
- In the XPages editor, select the list box.
- In the Properties view, click the List Box tab.
- With Visible selected (the default), click the computed property menu button.
- Select Compute value.
- In the script editor, select EL as the scripting language.
- Select Compute on Page Load.
- In the field, type this formula: return "list" == compositeData.get("display");.
- Click OK to close the script editor.
- Click
to save your changes.- Create an XPage and add the custom control to it.
- Select the custom control in the XPage.
- In the Properties view, click the All Properties tab.
- In the custom category, find the property called display.
- In the Value field, type list.
- Click
to save your changes.
To set property definition properties, do the following steps
Procedure
- Open the custom control as an independent design element in the editor.
- In the Properties view, click the Property
Definition tab. Note: By default, Domino® Designer provides a root node from which you can build the property tree. The root node does not have any properties.
- Click New Property to insert a new
property directly under the root node. By default, the first property
is called property_1. The next one is property_2,
then property_3, and so on. Note: Steps for creating groups of properties are below.
- On the right side of the Properties view,
click the Property tab, and do the following
steps:
- To set validation properties, click the Validation tab,
and do the following steps:
- Select the Required field check box if the property requires you to type a value for the property when the custom control is inside an XPage.
- In the script editor, type a JavaScript™ expression that produces a boolean. When true, the property value is considered valid.
- To set properties for making the property visible when the custom control is inside an XPage, click the Visible tab, and type a JavaScript™ expression that produces a boolean. When true, the property value is visible.
- Repeat the steps above for any new properties that you want to define for the custom control.
- To organize properties into groups, click New Group. By default, the first group property is called group_1. The next one is group_2, then group_3, and so on. Domino® Designer automatically adds a new property to the group by default.
- On the right side of the Properties view,
click the Group tab, and do the following steps:
- In the Name field, type the name of the group. The tree view to the left automatically gets updated with the new name.
- Select the Allow multiple instances check box if the group allows multiple values. If selected, you will be able to create multiple instances of the group when setting properties for the custom control inside an XPage.
- To set properties for making the group visible when the custom control is inside an XPage, click the Visible tab, and type a JavaScript™ expression that produces a boolean. When true, the group is visible.
- To delete properties and groups, select the property or group in the tree view and click Delete.
- To rearrange properties and groups in the tree view, select a property or group and click Move Up or Move Down.
- Click to save your changes.