You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sonu S <so...@gmail.com> on 2008/06/25 17:11:40 UTC

Struts list

 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

Thank you

Re: Struts list

Posted by Laurie Harper <la...@holoweb.net>.
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