struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: Struts list
Date Thu, 26 Jun 2008 18:56:16 GMT
Sonu S wrote:
>  HI,
> 
> I have to show list in my jsp page. I am using <html:select>
> 
> i am getting two lists from data base and it is in employee form bean: first
> list is for employee no and second list is for name. i want to display
> employee name in <option> and want to use employee no as VALUE in <option>
> so list would have employee no as value and name will be displayed to user.
> 
> i am not sure how to do it with two lists as i have two different lists, one
> list for emp no and one list for employee name. My form bean name is
> employeeForm and list names are employeeNoList and employeeNameList. Please
> help me... some code example would be a help for me. I am using struts 1.1

Your best bet is to zip the two lists together into a map and provide a 
getter on your form bean for that map. Failing that, you'll need to 
iterate one of the lists (using c:forEach or logic:iterate) and handle 
dereferencing into the other list explicitly. That might look something 
like this (untested):

   <html:select property="xxx" ...>
     <logic:iterate id="val" indexId="idx"
         name="employeeForm" property="emplyeeNoList">
       <option name="xxx" value="${val}">
         <bean:write name="employeeForm"
             property="employeeNameList[${idx}]"/>
       </option>
     </logic:iterate>
   </html:select>

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message