There are several components to this sample:
1. Webform Server Configuration
Webform Server Configuration
You must first change the default setting in the translator.properties:
Show link and enclosure in a new window.
Possible values are:
true - show in window. (default)
false - show in dialog.
The file can be found at C:\Program Files\IBM\Lotus Forms\Server\3.5\Webform Server\Translator
The form uses a simple button of type link to launch the dojo dialog:
<url compute="'countryState.html?instanceID=tempData&path=person&dataURL=' + URLEncode('http://' +. serverName.value +. ':' +. port.value +. '/' +. context.value +. '/GetCompanyObject?srcXML=countries.xml&xpath=countries/country&listLabel=label') + '&listLabel=label&listValue=abbrev&countryEl=country&stateEl=state'"></url>
The dataURL must be encoded to insure the special characters in are transferred properly.
In a more complex example your path may contain XPath predicates, if that is the case then the path must also be encoded. For example:
countryState.htm?instanceID=formData&path=' + URLEncode('Party[@id=&apos;Party_Insured_1&apos;]/Person')
Note also that the apostrophes in the string "'Party_Insured_1'" have been encoded in a very unique manner. We have replaced ' with "&apos;" if the apostrophe is not escaped in this way then the example will not function correctly.
The servlet provided will read a source xml file and convert it into a JSON object that can then be converted into the HTML list object. The servlet also caches the JSON object so that repeated requests will not incur the overhead of the conversion. The cached content will only exist for 1 day after the inital value is stored. If you want to rest the cache simply restart the WAS instance where the application is deployed.
The servlet accepts the following parameters:
srcXML = the filename that contains the XML to be loaded into the list
xpath = the XPath query that returns the nodeset from the srcXML
listLabel = defines the named object that will be used as the list label (only used to create a lowercase version to eliminate case comparisons)
debug = flag to enable debug tracing
Here is a brief look at a few of the key HTML components:
<body onload="makeMyAjaxRequest(createCountryData, replaceFormEncoding(unescape(getURLParam('dataURL'))), 'countryList', 'countryFilter');setHTMLFromForm('', getURLParam('instanceID'), '');">
When the HTML loads the AJAX call starts the work to load the list data.
<button class="doneButton" onClick="setCountryInForm(getSelectedListItemValue('countryList'));setStateInForm(getSelectedListItemValue('stateList'), getURLParam('instanceID'), 'state');setFocus();closeDialog();">Confirm Selection</button>
function setInstanceElement(textToSet, instanceID, path)
ibmForms[""].updateXFormsInstance(null, "instance('" + instanceID + "')/" + path, null, textToSet, XFDL.UFL_XFORMS_UPDATE_REPLACE_TEXT);
A sample war file and readme is enclosed that contains all the components and provides deployment instructions.
In the next release of the Webform Server there will be new hooks that allow the application designer to control the look of the Webform dialog, but for now, in 3.5.1, the dialog header, footer and size cannot be modified.
To deploy this application you must have (installed):
- WebSphere 6.x
- Webform Server 3.5x
Lotus Forms InfoCenter