In your form create two ArrayLists one for the values, one for the labels. If the data doesn't change much you can make them static. Create getter methods for them which populate the arraylists from you database (make sure you populate them in the same order so the labels correspond to the values. Then in your jsp do
<html:select property='dbfield'> <html:options property='arraylistofvalues' labelProperty='arraylistoflabels' /> </html:select> If you have really static stuff you can stick the above arraylists in the session or the context and use <html:select property='dbfield'> <html:options name='attributelabelname' labelName='attributevaluename' /> </html:select> Hope this helps. Edgar -----Original Message----- From: [EMAIL PROTECTED] [mailto:tbachta@;kcp.com] Sent: Friday, November 08, 2002 8:50 AM To: 'Struts Users Mailing List' Subject: Re: select and option tag issues I posted this question a couple of days ago and received an answer. Unfortunately the answer does not work for me. The problem I am having is on the initial page of my web application I have drop-down boxes that I want to be populated with information from a database. I have no problem getting the recordset but do not know how to transfer that recordset data into the drop-downs. I was able to populate the drop-downs similar to the example used in the documentation but that does not have an example of how to populate them with live data. Can anyone give me a quick lesson on how to do this. Tim Bachta Information Technology MC 48 816-997-7137 Eddie Bush <[EMAIL PROTECTED] To: Struts Users Mailing List <[EMAIL PROTECTED]> t> cc: Subject: Re: select and option tag issues 11/06/2002 11:52 AM Please respond to "Struts Users Mailing List" Have you discovered the collection attribute of the options tag? Your action can build any collection you desire (ie from a database -- see org.apache.struts.util.LabelValueBean for holding the name/value pairs). It then places that collection into some scope (whichever you like) and forwards to the page. Now, by specifying the key you used when placing the collection into scope as the value to the collection attribute of the options tag, you've got a dynamic drop-down populated from the database. ------------- in your Action subclass Collection c = ...; while (...) { String label = ...; String value = ...; c.add(new LabelValueBean(label, value)); } request.setAttribute("myCollection", c); ------------- in your JSP <html:select ... > <html:options collection="c" ... /> </html:select> (This isn't in the FAQ, is it? <goes-to-check/>) [EMAIL PROTECTED] wrote: >Hi all, > >I am very new to struts and I am trying to create combo boxes using the ><html:select><html:options> tags. I have been able to create and >populate them with string arrays placed on the JSP page similar to the >examples in the documentation. What I really need to do is populate >them based on information in a database. I can create the recordset >but after that I am lost. Can anyone please help. Thank you. Tim >Bachta > >Tim Bachta > -- Eddie Bush -- To unsubscribe, e-mail: < mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: < mailto:struts-user-help@;jakarta.apache.org> -- To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org> -- To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>