Creating a New UI Handler

There are two basic steps to creating your own UI handler:


Step 1. Register the UI Handler Information

When you start the eGuide server, it searches the \plugins\eGuide directory for XML files. The files located in this directory define what UI handlers are available in the Administration utility. See Accessing the eGuide Administration Utility. Therefore, you can create or modify existing UI handlers by adding or editing the files in this directory. The file can have any name but must have the .xml extension.

You need to define the UI handler, an ID, a name, and a description. You also need to specify the association to the Template Key or attribute syntax. To do this, use the attribute-name or syntax-name tags.

You can also specify which clients can use this handler. By using the Administration utility you can easily tell if the handler is capable of running various devices. See Accessing the eGuide Administration Utility. You can also specify multi-valued-enabled, single-valued-enabled, read-write-enabled, and read-only-enabled.

You need to define the class name for the Data handler. Data handlers let you use Java classes to change the way the information is retrieved and stored. For example, you could query a separate database to retrieve some information. However, most of the time you specify the Default Data Handler as shown in the example below.

Use the following handler definition as sample data to create the User Type handler. These examples can be found in the Customuihandler.xml document located in the \eGuide\web-inf\plugins\eGuide folder. You only need to uncomment the lines and restart eGuide to make them work:

<!-- ATTRIBUTE : User Type Selector --> 
<ui-attribute-handler>
<id>SVUserType</id>
<attribute-name>USERTYPE</attribute-name>
<class-name>com.novell.eguide.handler.LabeledURIDataHandler</class-name>

<client>browser</client>
<client>pocket</client>

<multi-valued-enabled/>
<single-valued-enabled/>
<read-write-enabled/>
<read-only-enabled/>

<display-name-key>User Type Selector</display-name-key>
<resource-properties-file>eguideresources</resource-properties-file>
</ui-attribute-handler>

After you define the same information in the XML file, restart the eGuide server. At this point, you can select the custom UI handler. However, when viewing the handler in the client, a warning message for the associated attribute displays. You need to complete the next step (Step 2. Define the Behavior of the UI Handler) to complete the process.


Step 2. Define the Behavior of the UI Handler

You use HTML, JavaScript, CSS, and other browser languages to define the way your information is displayed and edited by using.

For this example, uncomment the following xsl from the UIHandlers.xsl file located in the eGuide\web-inf\templates\xsl\default\browser directory:

<!-- SV Employee Type --> 
<xsl:when test="@uihandler='SVEmployeeType'">
<tr>
<xsl:call-template name="LabelTD"/>
<xsl:choose>
<xsl:when test="edit='true'">
<td class="ValueText">
<input type="hidden" name="{name}" id="{name}">
<xsl:attribute name="value"><![CDATA[<undefined><nochange></nochange></undefined>]]></xsl:attribute>
</input>
<select size="1" class="inputTextBox" name="_SV_CTRL_{name}" value="{value}" onchange="updateSvXml('document.forms[0]._SV_CTRL_{name}')">
<option value="Contract"><xsl:if test="value = 'Contract'"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>Contract</option>
<option value="Full Time"><xsl:if test="value = 'Full Time'"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>Full Time</option>
<option value="Internship"><xsl:if test="value = 'Internship'"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>Internship</option>
<option value="Part Time"><xsl:if test="value = 'Part Time'"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>Part Time</option>
<option value=""><xsl:if test="value = ''"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>(None)</option>
</select>
</td>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="MSV_GenericTextShowTD"/>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:when>

NOTE:  In order for changes to occur in a currently running system, you must either restart the server or enable XML Debug from the Administration utility under the Reporting - Debug settings. You use XML Debug for two reasons: to disable caching of the templates, and to cause the XML output of eGuide to be written to the console screen as well as the log files. These debug features slow down the server.

You can now select the UI handler for the EMPLOYEETYPE attribute, or any attribute with the Template Key mapped to EMPLOYEETYPE.