> From: "Barnett, Brian W." <[EMAIL PROTECTED]> > To: 'Struts Users Mailing List' > <[EMAIL PROTECTED]> > Subject: RE: <html:options> using java.util.Map > Date: Tue, 15 Jun 2004 13:44:00 -0500 > > If you don't use the collection attribute, and you > want different values and > labels in the list, you need to define two separate > collections, one for the > values and one for the labels. > > ArrayList statesValues = new ArrayList(); > statesValues.add("RS"); > statesValues.add("SC"); > statesValues.add("PR"); > ArrayList statesLabels = new ArrayList(); > statesLabels.add("Rio Grande do Sul"); > statesLabels.add("Santa Catarina"); > statesLabels.add("Paraná");
Or you could use a LabelValueBean: LabelValueBean[] schoolIds = new LabelValueBean { new LabelValueBean("Rio Grande do Sul","RS"), new LabelValueBean("Santa Catarina","SC"), new LabelValueBean("Parana","PR") }; If you make schoolIds a property on your ActionForm you're able to do this: <html:select property="schoolId"> <html:options property="schoolIds"> </html:select> I've always thought naming the options list the plural of the property I'm trying to set is the most straight forward naming convention: the user is selecting a schoolId from a list of valid schoolIds. If you still want to us a Map, I would use a LinkedHashMap so the order in which you add the elements is the same order in which they print out. - Ron __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]