We always use the options tag -

eg if I have a collection of beans with getters and setters for label and value
attributes in my form bean, I have the following in jsp:

            <bean:define id="reportsList" name="reportsMenuForm"
property="reportsList"/>
            <html:select property="reportToPrint"
onchange="processReportType(this)">
               <html:options collection="reportsList" property="value"
labelProperty="label"/>
            </html:select>

1.1 also has a new tag to avoid the bean:define, but we haven't migrated yet.

Cheers,

Dave





"Galbreath, Mark" <[EMAIL PROTECTED]> on 04/17/2002
09:58:51 AM

Please respond to "Struts Users Mailing List"
      <[EMAIL PROTECTED]>

To:   "'Struts Users Mailing List'"
      <[EMAIL PROTECTED]>
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  RE: [Q] select : Option - Urgent Help required.



No one on my team has been able to get the Collections iterator to work for
<html:options> so we are doing as I posted.  If you have some insight into
getting it to work, I'm all eyes!

Also, the iterate name should not be enclosed in JSP session variable
delimiters unless a method is being called to get the value.

Mark

-----Original Message-----
From: Stuart Jameson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 9:34 AM

You could use the <html:options> tag

-----Original Message-----
From: Galbreath, Mark [mailto:[EMAIL PROTECTED]]
Sent: 17 April 2002 13:45

I'm not totally clear on your Region or bean attributes, but the idea is
something like:

// bean property to set/get
<html:select property="selectedRegion">
// List to iterate, type is fully-qualified path,
// id is arbitrary, property is List element
  <logic:iterate name="<%= regions %>"
                 property="id"
                 type="Region"
                 id="region">
// set the option value
    <html:option value="<%= region.getId() %>">
// set the option label
      <bean:write name="region" property="String" />
    </html:option>
  </logic:iterate>
</html:select>

Mark

-----Original Message-----
From: Sanjay Choudhary [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 8:23 AM

> Need help with select option
>
> I have a formBean called RegionForm
>
> RegionForm contain attribute selectedregion:String
> and
> regions:ArrayList.
>
> regions:ArrayList is collection of object of class
> Region.
>
> Region class has attributes id and String.
>
> I wish to display on the form select option in the
> drop down box and populate it with all the items in
> the regions:Arraylist and display id attribute.
> Selected value should populate selectedregion:String
> in RegionForm.
>
> I tried nested:select and html:select but no
> success.

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








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

Reply via email to