Hi

Use :
html:optionsCollection name="MakeCollectionFormBean" property="values"
        
label="label" value="label" />

>From the docs:

This tag operates on a collection of beans, where each bean has a label
property and a value  property. The actual names of these properties can
be configured using the label and value attributes of this tag.

Use for instance ArrayList for MakeCollectionFormBean, not an ActionForm

Hermod

-----Opprinnelig melding-----
Fra: Gooshy GooSHY [mailto:[EMAIL PROTECTED]
Sendt: 16. august 2005 11:11
Til: user@struts.apache.org
Emne: Populate drop down box


Hi,

I'm pretty new to struts and haven't been using it for very long.  I
have spent the past few days trawling though web sites and usenet
trying to find the answer to my problem below.  If anyone can help it
would be much appreciated.

I am trying to find an example of code that will populate a collection
within a form bean and then forward it on to a jsp where the drop down
box will have the contents of the collection.

I have got the gist of how this is done but can't quite get the syntax
correct.  I have the following in my forwarded JSP:

<html:select property="makeText">
    <html:options collection="MakeCollectionFormBean" 
                         property="value" 
                         labelProperty="label"/>
</html:select>  

MakeCollectionFormBean is set up to only contain a getter and setter
for my Vector collections as shown below:

import java.util.Vector;

import org.apache.struts.action.ActionForm;

public class MakeCollectionFormBean extends ActionForm
{
        private Vector makes;

        public Vector getMakes() 
        {
                return makes;
        }

        public void setMakes(Vector makes) 
        {
                this.makes = makes;
        }
}

My Vector contains LabelValueBean objects.

If anyone can help with what should go where it would be really
helpfull.

Thanks
Scott.

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


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence with
customers as a part of an email. 

This email message has been virus checked by the virus programs used
in the DnB NOR Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


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

Reply via email to