> -----Original Message----- > From: Sri Sankaran [mailto:[EMAIL PROTECTED]] > Sent: 08 January 2003 14:06 > To: Struts Users Mailing List > Subject: RE: 'collection' dropdown trouble > > > If you look at the docs for <html:options> and in particular > for its 'collection' attribute you will note that the value > of the 'collection' attribute must be a java.util.Collection > of JavaBeans. Each bean in this java.util.Collection must > have the properties named by the 'property' and > 'labelProperty' attributes of the tag. > > So, working your way back from your JSP, since you have > > <html:select property="memPeriodFromMonths" > multiple="true"> > <html:options collection="memPeriodFromMonths" > property="label" > labelProperty="value"/> > </html:select> > > your form-bean must have a public getMemPeriodFromMonths() > method providing a java.util.Collection of JavaBeans. Each > of these beans must have public methods called getLabel() and > getValue(). >
Well not quite. Actually there is already Struts object called `LabelValueBean'. So what you create a Java Collection of LabelValueBean objects and return the collection in your action form bean. List list = new ArrayList(); list.add( new LabelValueBean( "0", "January" )); list.add( new LabelValueBean( "0", "February" )); ... list.add( new LabelValueBean( "11", "December" )); In the html:options tag itself. Did you know that any JavaBean can be used. This is why `property' is set `value' (getValue()) and why `labelProperty' is set `label' (getLabel()) Good luck -- Peter Pilgrim +44 (0)207-375-5642 *********************************************************************** Visit our Internet site at http://www.rbsmarkets.com This e-mail is intended only for the addressee named above. As this e-mail may contain confidential or privileged information, if you are not the named addressee, you are not authorised to retain, read, copy or disseminate this message or any part of it. The Royal Bank of Scotland plc is registered in Scotland No 90312 Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB Regulated by the Financial Services Authority *********************************************************************** -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>