Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Create a selection list with the Map keys as option values and the Map values as the option content.
This hack creates a pop-up selection list on a web page
from a Java Map. The list is made up
of a select tag with one or more
nested option tags. Each option can have a value attribute, which is what the web
application sends to the server instead of the content of the option. For example, the application sends
uk or fr in the following cases, not United Kingdom or France:
<select>
<option value="uk">United Kingdom</option>
<option value="fr">France</option>
</select>
This hack uses DWR to generate the pop-up from a Java Map, using Map keys as the values of the option value attributes. The hack uses the same web
page as that depicted in Figure 5-2, but it
generates the select element in a
slightly different manner. Here are the important parts of the web
page’s underlying HTML code, including the script tags that import various JavaScript
libraries and the select tag
itself: