I've put together a set of Struts examples at http://www.ninsky.com/struts,
one of which focuses on populating and options.

struts-config.xml:
  <form-bean name="optionsForm"
type="org.apache.struts.action.DynaActionForm">
    <form-property name="fruit3" type="java.lang.String[]" initial="Banana
Orange" />
  </form-bean>

JSP:
<html:select property="fruit3" size="7" multiple="true">
  <html:option value="Strawberry">Strawberry</html:option>
  <html:option value="Apple">Apple</html:option>
  <html:option value="Orange">Orange</html:option>
  <html:option value="Pear">Pear</html:option>
  <html:option value="Mango">Mango</html:option>
  <html:option value="Banana">Banana</html:option>
  <html:option value="Pineapple">Pineapple</html:option>
</html:select>

Here, I've set initial values in the DynaActionForm configuration, but you
could also initialise the values in your 'prepare' action.

Steve

> -----Original Message-----
> From: Daniel Massie [mailto:[EMAIL PROTECTED]
> Sent: July 31, 2003 5:02 AM
> To: Struts Users Mailing List
> Subject: RE: html:select multiple pre select
>
>
> I've tried this, I passed in Strin[] as the value, but no options were
> selected.
>   -----Original Message-----
>   From: Nagendra Kumar O V S [mailto:[EMAIL PROTECTED]
>   Sent: 31 July 2003 12:50
>   To: [EMAIL PROTECTED]
>   Subject: Re: html:select multiple pre select
>
>
>         hi.
>         docs say
>         a.. multiple="true" IS selected - The corresponding
> property should
> be an array of any supported data type.
>         so try populating the array (html:select property) with
> the required
> elements to be selected before hand.
>
>         -- nagi
>
>
>         -------Original Message-------
>
>         From: Struts Users Mailing List
>         Date: Thursday, July 31, 2003 05:02:03 PM
>         To: Struts Users Mailing List
>         Subject: html:select multiple pre select
>
>         I have a html:select with multiple="true" how can I get
> this to have
> options
>         highlighted when it loads? based on the elements already
> stored for
> this
>         select field.
>
>         Thanks
>
>         Daniel Massie
>
>
>
> --------------------------------------------------------------------
> -
>         To unsubscribe, e-mail: [EMAIL PROTECTED]
>         For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
>         .
>
>
>   ____________________________________________________
>     IncrediMail - Email has finally evolved - Click Here
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to