Widget definition file is to define the page element of the widget.
Here
is an example of widget definition file, Component.xml:
<iw:iwidget name="htmlWidget" xmlns:iw="http://www.ibm.com/xmlns/prod/iWidget" iScope="htmlWidget"
supportedModes="view" mode="view">
<iw:resource uri="htmlWidget.js" />
<iw:resource uri="utils.js"/>
<iw:resource uri="htmlWidget.css"/>
<iw:itemSet id="attributes" private="true">
<iw:item id="url" value=""/>
</iw:itemSet>
<iw:itemSet id="life" private="true">
<iw:item id="user" value='{"name": "Jesse" "phone": "110"}'/>
<iw:item id="fruit" value='["apple", "orange", "pear"]'/>
<iw:item id="movies" value='["Batman", "Leon", "The Godfather"]'/>
</iw:itemSet>
<iw:content mode="view">
<![CDATA[
<iframe class="rootFrame" style="width:100%;min-width:60px; min- height:200px;border:0px;"></iframe>
]]>
</iw:content>
<iw:content mode="view1">
<![CDATA[
<div id='userName'></div>
<input type="text" name="amount" id="amount" size="10" maxLength="10">
]]>
<div>
<input type="button" style="height=30px" value="OK" onclick='iContext.iScope().onClickButton1()'/>
</div>
</iw:content>
Parameters specification for each tag are as follows:
- component:
Table 1. Parameters specification for iWidgetParameter |
Description |
name |
The name of the widget, mandatory |
xmlms:iw |
The namespace of BTT widget, mandatory |
iScope |
The class name defined in the JavaScript™ file,
optional |
supportedModes |
The modes that the widget supports. In BTT Web 2.0 widget,
we support view, edit, max, collapse, refresh, close. The default mode is
view. Optional |
mode |
The default mode. The default value is “view”. Optional |
Table 2. Parameters specification for supportedModesParameter |
Description |
view |
The widget window can be initiated and displayed. |
edit |
The widget window will have an edit icon and its attributes
can be edited. |
max |
The widget window will have a maximization icon and
can be maximized. |
collapse |
The widget window will have a collapse icon and can
be collapsed. |
refresh |
The widget window will have a refresh icon and can be
refreshed. |
close |
The widget window will have a close icon and can be
closed. |
- resource indicates the JavaScript file or CSS file, mandatory.
The resource file can be shared in different widgets, and only load once.
Table 3. Parameters specification for resourceParameter |
Description |
uri |
The JavaScript or CSS file included, we
can define multiple uri in one widget XML file. |
- itemSet includes the attributes bounded with the widget.
You can define multiple itemSet.
Table 4. Parameters specification for itemSetParameter |
Description |
id |
The id of itemSet. Mandatory. |
private |
The scope of itemSet. BTT Web 2.0 widget support true
as the value, which means users can’t get the attribute of the itemset. Mandatory. |
item |
The items defined in itemSet, developer can define multiple
items in an itemSet. |
- item, the items defined in itemSet, developer can define
multiple items in an itemSet.
Table 5. Parameters specification for itemParameter |
Description |
id |
The id of item. Mandatory. |
value |
The value of item. Mandatory. |
- content contains the content that will be presented on
the web page. Developers can define multiple contents in one widget XML file.
Table 6. Parameters specification for contentParameter |
Description |
mode |
The mode of the content, the supported mode is view.
Mandatory |