Defining a widget

IBM® WebSphere® Multichannel Bank Transformation Toolkit widgets are defined in a .xml file. The .xml file describes how a widget is displayed in the XUI editor, the properties of the widget, and how the properties can be edited. The tables in this topic provide detailed descriptions of the tags in the widget definition file.

Figure 1 is a sample of a widget definition. For detailed descriptions of the tags and attributes in a widget definition file, see the following sections in this topic:
Figure 1. Sample of a widget definition
<widget xmlns="http://btt.ibm.com/WidgetSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://btt.ibm.com/WidgetSchema WidgetSchema.xsd ">
class="com.ibm.btt.alphasample.editor.figure.ToggleButtonSWT" /> -->
	<figure type="draw2d" class="org.eclipse.swt.widgets.Button" style="TOGGLE"/>
	  

	<properties>
		<!-- common properties -->
		<property name="id" type="String"/>
		<property name="width" default="50" />
		<property name="height" default="28" />
		<property name="visibility" default="visible" type="Visibility"
			showInAction="true" showInExpression="true" description="%desc_prop_visibility" />
		<property name="icon" type="Image" showInAction="true" showInEditor="true" 
			showInExpression="true" description="%desc_prop_icon" />			
		<property name="ontext" type="String" />
		<property name="offtext" type="String" />
		
	</properties>
	
	<events>
		<event name="onClick" description="%desc_event_onclick" />
		<event name="onKeyDown" description="%desc_event_onkeydown" />
		<event name="onKeyPress" description="%desc_event_onkeypress" />
		<event name="onKeyUp" description="%desc_event_onkeyup" />
		<event name="onMouseDown" description="%desc_event_onmousedown" />
		<event name="onMouseUp" description="%desc_event_onmouseup" />
		<event name="onMouseEnter" description="%desc_event_onmouseenter" />
		<event name="onMouseLeave" description="%desc_event_onmouseleave" />
		<event name="onMouseMove" description="%desc_event_onmousemove" />
		<event name="onChange" description="%desc_event_onchange" />
	</events>
	
	<functions>
		<function name="isFocusable" showInAction="false"
			showInExpression="true" returnType="Boolean" description="%desc_func_isfocusable" />
		<function name="focus" showInAction="true" showInExpression="false"
			description="%desc_func_focus" />
	</functions>
</widget>

The <figure> tag

By specifying the displaying class, the <figure> tag defines how a widget is displayed in the XUI editor. There are two types of figures for the implementation classes: draw2d and SWT. For a description of draw2d and SWT, see the Displaying a widget in the XUI editor topic.

Table 1. Attributes of the <figure> tag
Attribute Description
Type The type of class showing widget in XUI editor. Possible values are draw2d and SWT
Class The Class attribute specifies the class that is used to display a widget in the XUI editor
Style The Style attribute specifies the style of the widget. This attribute can be used only for the SWT type figure.

The <properties> tag

The <properties> tag lists the properties of a widget. Table 2 provides a description of the attributes of the <property> tag:

Table 2. Attributes of the <properties> tag
Attribute Description
Name The name of the property.
Default The default value of this property
Type The type of the property. For each property type, the property editor for this type is predefined. The value of the type attribute must be selected from Table 3. The default value is String.
showInEditor Determines whether to display this property in widget property view. Default value: true
showInExpression Determines whether to display this property in ECA expression. Default value: false
showInAction Determines whether to display this property in ECA action list. Default value: false
Description The description of this property, NLS support.
Level Reserved in current release.

Table 3 provides a description of the values for the type attribute of the <properties> tag.

Table 3. Values for the type attribute of the <properties> tag
Value Description
String Basic String type
Visibility Determines the visibility of widget. Possible values are: visible, hidden and gone
Boolean Basic Boolean type. Possible values are: yes and no
ButtonType Determines the type of button which user will create. Possible values are: button, submit and reset.
KeyBinding Determines the shortcut key of widget
DataName The name of field in BTT context
DataNameList The name of IndexedCollection of the BTT context. This type is used for Combo and SelectList widgets only
DataNameTreeContent The name of the data within the BTT context. This type is used for Tree widget only
Image The image of widget
NLS String with NLS support

The <events> tag

The <events> tag lists the events that are supported by a widget. Table 4 provides a description of the attributes for the <event> tag.

Table 4. Attributes of the <events> tag
Attribute Description
Name The name of the event
description The description of the attribute, NLS support.

The <function> tag

The <function> tag lists the functions that are supported by a widget. Table 5 provides a description of the attributes of the function tag.

Table 5. Attributes of the <function> tag
Attribute Description
Name The name of the function
description The description of the function, NLS support.
showInAction Determines whether to display this function in the ECA action list
showInExpression Determines whether to display this function in the ECA expression list
returnType Return type of the function. Possible values are: String, Number, Boolean
parameter Parameter list of the function

A function element can contain one or more parameter elements. Table 6 provides a description of the attributes for parameter element.

Table 6. Attributes of the parameter element
Attribute Description
Name The name of the parameter
description The description of the parameter, NLS support
Type The type of the parameter