I was in a hurry so I didn't expain much, sorry: Options tag: -collection is a TreeMap (a sorted map by key) in this example, but is can be anything that extends Collection. -property is the thing that will be assigned when the item is selected. Since I'm sorting on key I put my object id in the value position and the display value is my key. You can put them anywhere you want I just did this because I wanted my list sorted -labelProperty is the thing you'll see on the screen
> <html:select property="product.productId"> > <html:option key="option.default" value="" /> > <html:options collection="listofproducts" property="value" > labelProperty="key"/> </html:select> Suzette H. Daniel -----Original Message----- From: Alex Shneyderman [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 1:54 PM To: 'Struts Users Mailing List' Subject: RE: can I iterate on Map property? Cool I did not know. <%@ include file="/WEB-INF/templates/common/taglibs.jsp" %> <%@ page import="java.util.*" %> <% Map t = new HashMap (); t.put ("key1", "value1"); t.put ("key2", "value2"); t.put ("key3", "value3"); request.setAttribute ("myMap", t); %> <html:form action="/logon"> <html:select property="username"> <html:option key="option.default" value="" /> <html:options collection="myMap" property="value" labelProperty="key"/> </html:select> </html:form> > -----Original Message----- > From: Struts [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 24, 2003 1:46 PM > To: [EMAIL PROTECTED] > Subject: Re: can I iterate on Map property? > > Hi Suzette, > thanks for your reply, > am I correct to presume listofproducts in your example is of type Map? > Tex... > > "Suzette Daniel" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > news:[EMAIL PROTECTED] > > You can use the option tag with a Map, it works just fine, but you must > use > > html:options. Here's an example: > > > > <html:select property="product.productId"> > > <html:option key="option.default" value="" /> > > <html:options collection="listofproducts" property="value" > > labelProperty="key"/> </html:select> > > > > Suzette H. Daniel > > > > -----Original Message----- > > From: Alex Shneyderman [mailto:[EMAIL PROTECTED] > > Sent: Thursday, July 24, 2003 1:33 PM > > To: 'Struts Users Mailing List' > > Subject: RE: can I iterate on Map property? > > > > > > You might want to look at el tags. > > You can specify expressions in them to avoid iteration > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, July 24, 2003 1:23 PM > > > To: [EMAIL PROTECTED] > > > Subject: RE: can I iterate on Map property? > > > > > > No. Just use the <logic:iterate> tag. RTFM. > > > > > > -----Original Message----- > > > From: Struts [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, July 24, 2003 10:21 AM > > > To: [EMAIL PROTECTED] > > > Subject: can I iterate on Map property? > > > > > > > > > Hi all, > > > > > > in my form, I have a property of type Map. > > > I would like to render a select/option field in my html using this > > > property. Is this possible or do I need to convert it into an array? > > > > > > In either case, could some one be kind enough to show me an example? > > > > > > Thanks > > > Tex... > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

