Here is Mark's example refactored to use the <html:options> tag. <html:select property="ccExpYear"> <html:option value="0">Year</html:option> <html:options name="listExpYears"/> </html:select>
-- Jim "Galbreath, Mark" <[EMAIL PROTECTED]> writes: > Here's a simple example of how I retrieve a List of years to populate a > dropdown list: > > <html:select property="ccExpYear" styleId="ccExpYear"> > <html:option value="0">Year</html:option> > <logic:iterate id="expYear" name="listExpYears" scope="session"> > <html:option value="<%= ( String) expYear %>"> > <%= expYear %> > </html:option> > </logic:iterate> > </html:select> > > 1. The html:select property is a property in your bean, if one exists. > 2. styleId is just the HTML reference if you want to get a value with, say > JavaScript. > 3. The first html:option is the default "selected" option that displays. > 4. The logic:iterate id is arbitrary but required to reference the list's > elements. > 5. iterate name is the name of my ArrayList of years that I assigned to a > session > attribute in my action class: > > List listExpYears = new ArrayList(); > for( int k = 1; k < 11; k++) { > listExpYears.add(( new Integer( 2000 + > Calendar.getInstance().YEAR + k)) > .toString()); > } > request.getSession().setAttribute( > "listExpYears", listExpYears); > > 6. In html:option value, remember to cast the List objects to strings as > Struts is expecting a string. > > Easy as pie, eh? > > Mark > > -----Original Message----- > From: Roshan Paiva [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, April 24, 2002 3:17 PM > > > Hi... > > > > Could anyone pls tell me how to populate a dropdown list using struts > > tag libraries. > > > > I have an arraylist of databeans.. The dropdown list should skim > > through each item in the arraylist and take the value of > > databean.getFirstValue() (or the firstValue property of the data > > bean). I believe the tag is html:select. However I am not certain on > > how to use it. > > > > Kind Regards > > Roshan > > > > -- > 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]>