struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anjib Mulepati <anji...@hotmail.com>
Subject Using <html:select> tag
Date Thu, 22 Sep 2011 16:49:06 GMT
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
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message