Is there any way to mark an option as selected by default, much like the selected
attribute in the HTML option
tag like <option value="value1" selected>
?
views:
66answers:
2
A:
If the path value of the tag matches the value of options value it will automatically be selected. You don't need anything special
Teja Kantamneni
2010-06-25 19:31:54
I understand that, but some business logic needs me to have a default selected item the first time it loads (subsequent loads, select list goes away and is replaced by a hidden field).
Eqbal
2010-06-25 19:38:28
Set that as the default value for that field in command object.
Teja Kantamneni
2010-06-27 16:45:28
A:
Is there any way to mark an option as selected by default ???
Just use <spring:option Taglib The first one will be automatically selected
<spring:select name="someProperty">
<spring:option value="">Select one</spring:option>
<spring:option value="someValue">Some value<spring:select>
<!--And so on...-->
<spring:select>
or
<spring:select name="someCollection">
<spring:option value="">Select one</spring:option>
<!--Here goes some List added to request-->
<spring:options itemLabel="propertyNameUsedAsLabel" itemValue="propertyNameUsedAsValue"/>
<!--And so on...-->
<spring:select>
Arthur Ronald F D Garcia
2010-06-29 02:12:57