BTT provideds several default definitions for table column widget in XUI Editor. Besides, the widgets displayed in a table column, their properties and customized rules for JSP generation could also be extended through Eclipse extension points and BTT XML definitions.
If you need to customize table column widgets in your self-defined plug-in project, the prerequisite is to add plug-in ‘com.ibm.btt.tools.xui.editor2’ as the plug-in dependency.
To add a new widget into the widget
selection list of a table column, firstly you need to declare an Eclipse
extension for the extension point 'com.ibm.btt.tools.xui.editor2.widgets'.
Then,
right click the newly added extension and choose to add a child option
from the context menu. If you need to define a common XUI widget which
could also be used as a table column widget, you should choose the
option ‘widget’; otherwise, you should choose the option ‘internalWidget’
which means the extended widget is only for table column. See the
picture above.
Then, move to its details panel to fill in the required attributes (name, label, icon and config) for the widget register. For the attribute ‘conifg’, you should choose or specify a relative path of the widget definition file. See the picture above. Later, you will take steps to create a XML file to describe this widget.
<columnWidget editable="false"/>
Attribute | Description |
---|---|
name | The attribute to identify the column widget. It is optional and the widget name registered in extended plug-in will be used if this attribute is not defined. |
editable | The available values are ‘true’ and ‘false’ which indicate whether the widget could be chosen as a editable one or not for a table. Besides, it is optional and the widget could be chosen from both editable and read-only widget list in table properties view. |
addTypeInfo | This attribute is optional and asks for a Boolean value. It will be used if the widget needs to be bound with a BTT typed data. If it is set to true, the generated jsp tag of the widget will contain the attribute named ‘type’. |
The sample code snippet of this column widget definition
is listed below.
<property name="visibility" default="visible" type="Visibility" showInColumn="true"/>
Attribute | Description |
---|---|
name | The attribute is used to define the property name. It is required; otherwise this property will be ignored during generation. |
type | The attribute is used to indicate which property editor will be used for this property. The value of it should equals with one of the registered property editor ID in existing BTT toolings. It is required; otherwise the property editor will be disabled in editor. |
default | The attribute is used to indicate the default value of this property. The generated JSP tag will contain this default value attribute if it is defined. It is an optional one. |
showInColumn | The attribute asks for a Boolean value which defines whether this property is available when this widget is used for a table column. |
The sample code snippet of this column widget definition
is listed below.
If
there are some special logics to be injected during the JSP generation,
such as extra conversion for the names and values of JSP tag attributes,
you need to define a mapping rule for the column widget..
Attribute | Description |
---|---|
widgetName | The attribute is used to link the generation rules with the registered column widget. It is required otherwise the rules could not be assigned correctly. So its value should equals with column widget identifier. |
tagName | The attribute is required and used to indicate the JSP tag name for column widget generation. |
Attribute | Description |
---|---|
propName | The attribute is used to indicate the identifier of the property which needs extra generation logic. |
attrName | The attribute is used to indicate that the property name will be replaced with the value of ‘attrName’ during JSP generation. It is used for conversion of JSP attribute name. |
rule | The attribute is used to indicate the identifier of a registered mapping rule. It is used for conversion of JSP attribute value. |
Finally,
if you decide to use the extra rule to control the value generation
of JSP attributes, you need also register the rule into BTT tooling
extension to indicate the path of the configuration file which contains
the mapping rules. For that, you could define an extension for the
extension point 'com.ibm.btt.tools.xui.editor2.generator'. Then like
the picture below, add a child option of type 'rule'.
Like
the picture shown below, the required attributes 'name' and 'class'
should be configured. Especially for the attribute 'class', you need
to indicate the full path to a class which implements the interface
'com.ibm.btt.tools.xui.editor2.generator.IRule'. During the JSP generation,
the class would be instantiated and executed for the configured mapping
rules.
So, what you need to do is to add your codes for the
attribute value conversion like the snippet above.