Hi David, Here is an example. In this example, homeDepartmentRoles is a String[], representing all of the roles that a particular user has. The "roles" collection in the <html:options> tag is a Collection of LabelValueBean objects (see http://jakarta.apache.org/struts/api/org/apache/struts/util/LabelValueBean.h tml). The LabelValueBean objects in the collection represent ALL items in the select list. To put it another way, the collection specified in the <html:options> tag should have ALL items you want to display in your select box, whereas the <html:select> "property" attribute is the array that stores all items which will show up selected when the select box is displayed.
<html:select property="homeDepartmentRoles" multiple="true"> <html:options collection="roles" property="label" labelProperty="value"/> </html:select> This can be done a number of different ways, but this is the best way that I have found works for my needs. HTH, Justin ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 8:07 AM Subject: RE: dropdowns being reset > > Is there any way you could mail me sample code for this Options tag? > > Thanks, > David > > > > shirishchandra.sakhare@ubs. > com To: [EMAIL PROTECTED] > cc: > 12/12/2002 12:33 Subject: RE: dropdowns being reset > Please respond to "Struts > Users Mailing List" > > > > > > try using html:options instead..and supply it with the collection or array > of > indexes... > > because if in html:select u specify property attribute, and the property is > > there in the request(which should be the case when u forward the request > back > to same jsp with errors..),the same is used to preselect a element. > I think may be as u are using html:ootion in a loop, u are having this > problem. > > regards, > Shirish > > -----Original Message----- > From: david.heagney [mailto:[EMAIL PROTECTED]] > Sent: Thursday, December 12, 2002 1:17 PM > To: struts-user; david.heagney > Subject: dropdowns being reset > > > Hi, > > I have a page in my STRUTS app which dynamically populates a dropdown list: > > Month > > <html:select property="fromMonth"> > <option value="--">-- > <% for (int i=1; i <= 12; i++) { %> > <option value="<%= i %>"><%= getMonthName (i) %> > <% } %> > </html:select> > > getMonthName() returns the month as a string based in the passed integer, 1 > - 12. > > If the user submits the form and leaves out a required field, the above > dropdown gets re-set, i.e. doesn't retain the selection when the page is > refreshed with it's errors... does anyone know how i can avoid this? > > 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:[EMAIL PROTECTED]> > For additional commands, e-mail: < > mailto:[EMAIL PROTECTED]> > > > > -- > To unsubscribe, e-mail: < > mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: < > mailto:[EMAIL PROTECTED]> > > > > > 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:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>