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 ------------------------------------------------------------------------------ - === HTML SELECT element === + == Dropdown box == - Use <html:select> tag to create HTML SELECT widget. + Use <html:select> tag to create HTML SELECT element that can be rendered either as dropdown box or a listbox. To create a dropdown box set ''size'' less than 2 or do not specify ''size'' at all. {{{ <html:select name="addressForm" property="currentStateCode" size="1"> @@ -10, +10 @@ </html:select> }}} - HTML SELECT can be rendered either as dropdown box or as a listbox. To create a dropdown box set ''size'' less than 2 or do not specify ''size'' at all. To create a listbox specify ''size'' larger than 1. + HTML SELECT can be rendered either as dropdown box or as a listbox. To create a listbox specify ''size'' larger than 1. <html:select> tag specifies current value: * ''name'' is the name of plain java bean or an action form; optional @@ -33, +33 @@ You still need to use ''property'' attribute to store value submitted by user. + == Listbox == + + Use <html:select> tag to create HTML SELECT element. Specify number of rows in the lisbox using ''size'' attribute. You must set size larger than 1, otherwise SELECT element will be rendered as a dropdownbox. + + {{{ + <html:select name="addressForm" property="currentStateCode" size="3"> + <html:optionsCollection name="stateList" value="stateCode" label="stateName"/> + </html:select> + }}} + + See previous section (dropdown box) for usage details. + + == Radio Button == + + Use <html:radio> tag to create HTML INPUT element having type "radio". + + {{{ + <html:radio name="addressForm" property="currentStateCode" value="CA"/> California + }}} + + <html:radio> tag uses following attributes: + * ''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 + * ''value'' is the static value assigned to a particular radio button + + inline:radiobuttonwidget.gif + + Radio button is checked if actual value stored of the ''property'' equals to ''value'' attribute. In the above example, the checkbox is checked if addressForm.currentStateCode.equals("CA"). + + Radio button does not have a label. You need to print it yourself beside the input element, like "California" is printed above. + + == Radio Group == + + Use <logic:iterate> and <html:radio> tags to create series of HTML INPUT elements having type "radio". + + {{{ + <logic:iterate id="choice" name="stateList"> + <html:radio name="addressForm" property="currentStateCode" idName="choice" value="stateCode"/> + <bean:write name="choice" property="stateName"/> + <br> + </logic:iterate> + }}} + + inline:radiogroup.gif + + <logic:iterate> tag uses following attributes: + * ''name'' is the name of a collection that holds possible values and labels of radio buttons + * ''id'' is the name to use for current collection element while iterating over the collection + + <html:radio> tag uses following attributes: + * ''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 + * ''idName'' corresponds to ''id'' attribute from <logic:iterate> tag; id identifies a collection element that is being processed + * ''value'' is the name of collection property that contains radio button value + + <html:radio> tag uses following attributes: + * ''name'' identifies a collection element that is being processed + * ''property'' is the name of collection property that contains radio button label + + In the above example a radio button is checked if addressForm.currentStateCode.equals(choice.stateCode). + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]