Dear Wiki user, You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.
The following page has been changed by MichaelJouravlev: http://wiki.apache.org/struts/StrutsWidgets The comment on the change is: Added tip about using Map in optionsCollection ------------------------------------------------------------------------------ * ''name'' is the name of plain java bean or an action form; optional * ''property'' is the property in the java bean that holds current value - <html:optionsCollection> specifies the collection that contains selectable items: + <html:optionsCollection> specifies the collection that contains selectable items. The above sample uses List: - * ''name'' is the collection name; can be defined in any scope; + * ''name'' is the collection name, can be defined in any scope; - * ''value'' specifies the property containing item value; corresponds to ''property'' from <html:select> tag + * ''value'' specifies the property containing item value; * ''label'' specifies the property containing item label; this is what is shown to a user. + + When the widget is being displayed, it positions to an element that has the same ''value'', as the ''property'' specified in <html:select> tag. inline:selectwidget.gif + Using Map is slightly different from using List. When a Map is iterated, it exposes each entry as a Map.Entry record with attributes ''key'' and ''value''. Selectable item is stored in ''value'' attribute of Map.Entry: + + {{{ + <html:select name="addressForm" property="currentStateCode" size="1"> + <html:optionsCollection name="stateMap" value="value.stateCode" label="value.stateName"/> + </html:select> + }}} + - If you want a listbox to always position to a certain hardcoded value instead of value submitted by user, add ''value'' attribute to <html:select> tag. For example, this code always displays "California" despite of currently chosen value: + If you want a listbox to always position to a certain hardcoded value instead of value submitted by user, use ''value'' attribute to <html:select> tag. For example, this code always displays "California" despite of currently chosen value: {{{ <html:select name="addressForm" property="currentStateCode" value="CA" size="1"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]