The event-driven model is simple and powerful, but it might not be practical to rewrite all servlets to replace with event listeners.
The name Property
To work with legacy Web applications, you could specify the name property as you did for HTML pages. For example,
<window xmlns:h="[http://www.w3.org/1999/xhtml http://www.w3.org/1999/xhtml]"> <h:form method="post" action="/my-old-servlet"> <grid> <rows> <row> When <datebox name="when" /> Name <textbox name="name" /> Department <combobox name="department"> <comboitem label="RD" /> <comboitem label="Manufactory" /> <comboitem label="Logistics" /> </combobox> </row> <row> <h:input type="submit" value="Submit" /> </row> </rows> </grid> </h:form> </window>
Once users press the submit button, a request is posted to the my-old-servlet servlet with the query string as follows.
Thus, as long as you maintain the proper associations between name and value, your servlet could work as usual without any modification.
Components that Support the name Property
All input-types components support the name property, such as textbox, datebox, decimalbox, intbox, combobox, bandbox, slider and calendar.
In addition, list boxes and tree controls are also support the name property. If the multiple property is true and users select multiple items, then multiple name/value pairs are posted.
<listbox name="who" multiple="true" width="200px"> <listhead> <listheader label="name"/> <listheader label="gender"/> </listhead> <listitem value="mary> <listcell label="Mary"/> <listcell label="FEMALE"/> </listitem> <listitem value="john"> <listcell label="John"/> <listcell label="MALE"/> </listitem> <listitem value="jane"> <listcell label="Jane"/> <listcell label="FEMALE"/> </listitem> <listitem value="henry"> <listcell label="Henry"/> <listcell label="MALE"/> </listitem> </listbox>
If both John and Henry are selected, then the query string will contain:
Notice that, to use list boxes and tree controls with the name property, you have to specify the value property for listitem and treeitem, respectively. They are the values being posted to the servlets.
Rich User Interfaces
Because a form component could contain any kind of components, the rich user interfaces could be implemented independent of the existent servlets. For example, you could listen to the onOpen event and fulfill a tab panel as illustrated in the previous sections. Yet another example, you could dynamically add more rows to a grid control, where each row might control input boxes with the name property. Once user submits the form, the most updated content will be posted to the servlet.
|Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.|