WebWork 2 : Select tag
This page last changed on Dec 14, 2004 by casey.
<ww:select />Generates a select list filled with a specified list. The "listKey" attribute is the property to pull from each item in the list to generate the value of the <option> tag for that item. The "listValue" attribute fills the label of the option (the display name). One great feature is that it will auto-select the appropriate option based on the "value" attribute. If the value matches the current listKey, that option will be selected (if the types match; see below).<ww:select label="'Users'"
name="'userId'"
listKey="id"
listValue="name"
list="app.users"
value="app.user.id"
onchange="'chooseUser(this)'"
/>
will create the following (if getApp().getUser().getId() == 2): <tr> <td>Users</td> <td> <select name="userId" onchange="chooseUser(this)"> <option value="1"> User Number One </option> <option value="2" selected="selected"> User Number Two </option> </select> <td> </tr> Sample Usages <ww:select label="'Pets'" name="'petIds'" list="petDao.pets" listKey="id" listValue="name" multiple="true" size="3" required="true" /> <ww:select label="'Months'" name="'months'" list="#{'01':'Jan', '02':'Feb', [...]}" value="selectedMonth" required="true" /> // The month id (01, 02, ...) returned by the getSelectedMonth() call // against the stack will be auto-selected Attributes
|
![]() |
Document generated by Confluence on Dec 14, 2004 16:36 |