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>

Of course, the <td> formatting and such depends on the template you are using.

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

Note: For any of the tags that use lists (select probably being the most ubiquitous), which uses the OGNL list notation (see the "months" example above), it should be noted that the map key created (in the months example, the '01', '02', etc.) is typed. '1' is a char, '01' is a String, "1" is a String. This is important since if the value returned by your "value" attribute is NOT the same type as the key in the "list" attribute, they WILL NOT MATCH, even though their String values may be equivalent. If they don't match, nothing in your list will be auto-selected.

Attributes
Name Required Description
id no HTML id attribute
name yes HTML name attribute
value no Data to pass as field value
required no Is field required for form submission
list no Iteratable source to populate from. If the list is a Map (key, value), the Map key will become the option "value" parameter and the Map value will become the option body.
listKey no Property of list objects to get field value from
listValue no Property of list objects to get field content from
emptyOption no Whether or not to add an empty (--) option after the header option
multiple no Is this a multiple select?
size no Size of the element box (# of elements to show)
disabled no HTML disabled attribute
tabindex no HTML tabindex attribute
onchange no HTML onchange attribute
onclick no HTML onclick attribute
headerKey no Key for first item in list
headerValue no Value for first item in list
label no Text used as label in template
labelposition no Alignment of label (left,right,center)
cssClass no HTML class attribute
cssStyle no HTML style attribute
theme no Theme to use
template no Name of template to use

Document generated by Confluence on Dec 14, 2004 16:36