struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Java Guru" <j4v4g...@gmail.com>
Subject Re: How to use <html:select> for multiple fields of form
Date Fri, 02 Mar 2007 18:18:16 GMT
Hi Every One,

    I solved the problem. I crated another filed fullName in
Persons.javaand added setter and getter methods for it. I used the
following statement
to populate select
---------------------------------------------------------------------------------------------------------------------------------------------------------------
   <html:select property="from">
                        <html:options collection="personslist"
property="personId"  labelProperty="fullName"/>
   </html:select>
----------------------------------------------------------------------------------------------------------------------------------------------------------

This code solved my issue. If there is any better answer for this problem
then I will be happy to hear from you.

:):D;)
Java Guru.





On 3/2/07, Java Guru <j4v4guru@gmail.com> wrote:
>
> Hi every one,
>
>    I have a Question for you. I am trying to display and attribute of
> session on a form.It is something like this on normal jsp.
>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> <select name="from">
>
>                 <%
>                         HttpSession sess=request.getSession();
>                         List
> personslist=(List)sess.getAttribute("personslist");
>                         Iterator personite=personslist.iterator();
>                         while(personite.hasNext()){
>                         Persons person= (Persons)personite.next();
>                         %>
>                         <option value=<%=person.getPersonId()%>><%=
> person.getFirstName()%>, <%=person.getLastName()%></option>
>                         <%}%>
>                     </select>
>
> ================
> Persons.java
> ================
> class Persons{
> int PersonId;
> String firstName();
> String lastName();
>
> //and all setter and getter methods.
> }
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> I want to change this to Struts. I am not able to understand how can I
> show all 3 fields PersonID, firstName and lastname in Option tag of
> selection field. As of now this code is working fine in normal JSP. But I
> want to convert this to Struts. Please help me.
>
> thank you,
> Javaguru.
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message