You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jose Casas <Jo...@wal-mart.com> on 2002/03/25 23:35:04 UTC

dynamic select box

Hi,

I'm new to struts and was wondering if anybody knew how create a select box
with struts.  I have a bean which is returning an ArrayList.  I want to use
this ArrayList as the options in the select tag.  What code do I need in my
jsp to create this select box?   Can somebody please help me?

Jose Casas

E-Commerce Applications
(501) 277-3112
jcasas@wal-mart.com



**********************************************************************
This email and any files transmitted with it are confidential
and intended solely for the individual or entity to 
whom they are addressed.  If you have received this email 
in error destroy it immediately.
**********************************************************************

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: dynamic select box

Posted by Joseph Barefoot <jo...@hereuare.com>.
This is how we do it:

  <html:select name="yourActionForm" property="fieldToHoldSelectedValue">
          <html:options collection="yourArrayList" property="optionValue"
labelProperty="optionLabel"/>
  </html:select>

The ArrayList (in yourActionForm bean) should contain a list of Objects
(call it a KeyValuePair bean or something) which contain "getOptionValue"
and "getOptionLabel" methods (method names match the values in the JSP tag).
Struts will look for these methods to retrieve the proper values from each
Object in the ArrayList and populate the html tags with them.

The "fieldToHoldSelectedValue" field in yourActionForm will be set to the
value the user picks when the HTML form is submitted.


-----Original Message-----
From: Jose Casas [mailto:Jose.Casas@wal-mart.com]
Sent: Monday, March 25, 2002 2:35 PM
To: 'Struts Users Mailing List'
Subject: dynamic select box


Hi,

I'm new to struts and was wondering if anybody knew how create a select box
with struts.  I have a bean which is returning an ArrayList.  I want to use
this ArrayList as the options in the select tag.  What code do I need in my
jsp to create this select box?   Can somebody please help me?

Jose Casas

E-Commerce Applications
(501) 277-3112
jcasas@wal-mart.com



**********************************************************************
This email and any files transmitted with it are confidential
and intended solely for the individual or entity to
whom they are addressed.  If you have received this email
in error destroy it immediately.
**********************************************************************

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>