Wiki Markup |
---|
{scrollbar} |
Excerpt | ||
---|---|---|
| ||
Using SelectModel, SelectModelFactory and ValueEncoder for Select menus populated from a database |
...
The documentation for the Select Component and the Tapestry Tutorial provide simplistic examples of populating a drop-down menu (as the (X)HTML Select element) using comma-delimited strings and enums. However, most real-world Tapestry applications need to populate such menus using values from a database, commonly in the form of java.util.List objects. Doing so generally requires a SelectModel and a ValueEncoder bound to the Select component with its "model" and "encoder" parameters:
...
In the above example, ColorSelectModel must be of type SelectModel, or anything that Tapestry knows how to coerce into a SelectModel, such as a List or a Map or a "value=label,value=label,..." delimited string, or anything Tapestry knows how to coerce into a List or Map, such as an Array or a comma-delimited String.
SelectModel
Wiki Markup |
---|
{float:right|background=#eee|padding=0 1em}
*JumpStart Demos:*
[Total Control Object Select|http://jumpstart.doublenegative.com.au/jumpstart/examples/select/totalcontrolobject]
[ID Select|http://jumpstart.doublenegative.com.au/jumpstart/examples/select/id]
[Easy ID Select|http://jumpstart.doublenegative.com.au/jumpstart/examples/select/easyid]
{float} |
...
In addition to a SelectModel, your Select menu is likely to need a ValueEncoder. While a SelectModel is concerned only with how to construct a Select menu, a ValueEncoder is used when constructing the Select menu and when interpreting the encoded value that is submitted back to the server. A ValueEncoder is a converter between the type of objects you want to represent as options in the menu and the client-side encoded values that uniquely identify them, and vice-versa.
Wiki Markup |
---|
{float:right|background=#eee|padding=0 1em}
*JumpStart Demo:*
[Easy Object Select|http://jumpstart.doublenegative.com.au/jumpstart/examples/select/easyobject]
{float} |
...