struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Childers" <jchild...@hotels.com>
Subject RE: how to populate drop down list
Date Fri, 11 Jul 2003 11:27:01 GMT
> 	How can I populate dropdown list from form bean? What is the
> structure of getter and setter methods required?
> 
> 	Actually the values of drop down list are coming from database
> which gets populated into the form bean now from form bean 
> how can that be populated in dropdown list?

Try this.

In your Action:

    ArrayList months = new ArrayList();
    months.add(new LabelValueBean("January", 1);
    months.add(new LabelValueBean("Februrary", 2);
    request.setAttribute("months", months);

Inside your JSP:

    <html:form action="/yourActionMapping">
	<html:select property="yourFormProperty" multiple="true">
	    <html:options collection="months" property="value" labelProperty="label" />
	</html:select>
    </html:form>

> Also how can the reverse of this, that is once I select multiple selections from 
> this list are set into the form bean?

Make your Form attribute a String[].

-= J

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message