Hey Anjib, 1 - Check out the tablib docco ( http://struts.apache.org/2.x/docs/select.html). For example with html:select you could use listKey and listValue. Should be something similar for html:options. I always use html:select though as much less code for what I need. 2 - Have your action implement Preparable. Then in the prepare method you load the agency names.
Hope that helps. Carl. On Thu, Sep 22, 2011 at 6:49 PM, Anjib Mulepati <anji...@hotmail.com> wrote: > Hi All, > > I have two question > 1. regarding understanding <html:option>, <html:options> and > <html:optionsCollection> and > 2. reloding option items after form validation fail. > > I have agency bean with (ID, Name). I create list of agency as agencyList. > I have login page which have select/option box and it get value from the > DB. So my action class set that list in session variable > session.setAttribute("**agencyList", agencyList); > Login form itself have three attributes and getter/setter with validation > method > private String agencyName; > private String userName; > private String password; > In JSP I am trying to use that list as follow > <html:select title="Agency" styleId="agencyName" property="agencyName" > tabindex="1"> > <logic:iterate id="agency" name="agencyList"> > <html:option value="agencyId" ><bean:write name="agency" > property="agencyName"/></html:**option> > </logic:iterate> > </html:select> > > This shows me the list but value is always "agencyId". Is there any easy > way so that I can read both 'id' and 'name' from bean and put in option tag > 'ID' as 'value' and 'name' as 'label'. > Couldn't fig out which one to use <html:option>, <html:options> and > <html:optionsCollection>. > > Second problem is if my validation fail in this login page. I get blank > page due to null agencyList. So I am trying to fig out how to populate the > agencyList again after form validation fail. > > Thanks > > > > > > ------------------------------**------------------------------**--------- > To unsubscribe, e-mail: > user-unsubscribe@struts.**apache.org<user-unsubscr...@struts.apache.org> > For additional commands, e-mail: user-h...@struts.apache.org > >