Example:

<bean:define id="list" name="servicesForm" property="services"
type="java.util.Vector"/>

<html:select size="5" property="services" styleClass="FieldText">
        <html:options collection="list" property="code"
labelProperty="name"/>
</html:select>

Here, servicesForm is the bean and it has a property called services of
type Vector. The "services" property contains a list of objects for whom
get/set methods are defined on "code" and "name" properties again.

Suresh

>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
>Sent: Wednesday, January 08, 2003 5:25 PM
>To: [EMAIL PROTECTED]
>Subject: 'collection' dropdown trouble
>
>
>Hi,
>
>I'm a STRUTS newbie and I've been trying to get a 'collection' 
>dropdown to
>work for what must be a couple of weeks now...
>
>The code I'm using to display the dropdown in my JSP is:
>
><html:select property="memPeriodFromMonths" multiple="true">
>   <html:options collection="memPeriodFromMonths" property="label"
>labelProperty="value"/>
></html:select>
>
>Then my getter and setter methods are:
>
> public Vector getMemPeriodFromMonths() {
>
>     for (int i=1; i <= 12; i++) {
>         memPeriodFromMonths.add(getMonthName (i));
>     }
>
>     return memPeriodFromMonths;
> }
>
>public void setMemPeriodFromMonths(String newMemPeriodFromMonths) {
>
>    memPeriodFromMonths = newMemPeriodFromMonths;
>
>  }
>
>public String getMonthName (int monthNumber) {
>
>      String strReturn = "";
>      switch (monthNumber){
>
>          case 1:
>              strReturn = "Jan";
>              break;
>        case 2:
>              strReturn = "Feb";
>              break;
>          case 3:
>              strReturn = "Mar";
>              break;
>          case 4:
>              strReturn = "Apr";
>              break;
>          case 5:
>              strReturn = "May";
>              break;
>          case 6:
>              strReturn = "Jun";
>              break;
>          case 7:
>              strReturn = "Jul";
>              break;
>          case 8:
>              strReturn = "Aug";
>              break;
>          case 9:
>              strReturn = "Sep";
>              break;
>          case 10:
>              strReturn = "Oct";
>              break;
>          case 11:
>              strReturn = "Nov";
>              break;
>          case 12:
>              strReturn = "Dec";
>              break;
>      }
>
>      return strReturn;
>
>  }
>
>
>Can anyone tell me what I'm doing wrong? Or mail me working 
>sample code so
>I can compare?
>
>Thanks,
>David
>
>
>This message is for the designated recipient only and may contain
>privileged, proprietary, or otherwise private information.  If you have
>received it in error, please notify the sender immediately and 
>delete the
>original.  Any other use of the email by you is prohibited.
>
>
>--
>To unsubscribe, e-mail:   
><mailto:struts-user->[EMAIL PROTECTED]>
>For 
>additional commands, 
>e-mail: <mailto:[EMAIL PROTECTED]>
>

**************************Disclaimer************************************************** 
   
 
 Information contained in this E-MAIL being proprietary to Wipro Limited is 
'privileged' 
and 'confidential' and intended for use only by the individual or entity to which it 
is 
addressed. You are notified that any use, copying or dissemination of the information 
contained in the E-MAIL in any manner whatsoever is strictly prohibited.

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




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

Reply via email to