Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Direct Web Remoting (DWR)for Java Joc... > Hack #45. Use DWR to Create a Select...

Hack #45. Use DWR to Create a Selection List from a Java Map

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:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint