struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Qasim Khawaja <Qasim.Khaw...@admin.ox.ac.uk>
Subject Re: how to populate drop down list
Date Fri, 11 Jul 2003 16:23:55 GMT
Is that the Action or the ActionForm? If it is the Action when is it 
called prior to the display of the form and what is the entry point or 
means to determine that its a display form request as opposed to posting 
the html form?

James Childers wrote:
>>	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