struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sashi Ravipati" <>
Subject RE: what setters do i implement in an indexed tag --NewBiequestion
Date Thu, 12 Jun 2003 12:49:00 GMT

Thanks for all the code u sent. I have started working on it, and I had
few questions (PLS bear with me if they look stupid).

1. PersonForm (which extends ActionForm) will have get and set methods 
for Name and Phone Number? This PersonForm is also initialized in

2. IS myFormBean another bean which extends ActionForm ? Do I need to
set this also in my Struts-Config.xml 


>>> 06/11/03 06:45PM >>>
Forgot to mention, I believe for the case of indexing using
logic:iterate your id must match your property. So in your example set

Now if you switch over to nested:iterate, the whole id thing goes away
and the property and type attributes are sufficient.


-----Original Message-----
From: John Greenhill []
Sent: Wednesday, June 11, 2003 3:37 PM
To: Struts Users Mailing List
Subject: RE: what setters do i implement in an indexed tag

Assuming you're NOT using the lazy initialization, you could do it like

1) your iterate will need to specify the type of the nested class:

<logic:iterate id="person" name="myFormBean" property="personList"

Where the Person class has just the standard accessors for name and

2) Your myFormBean will have the special accessors for indexing:

    public Person getPersonList(int ndx) {
        return (PersonForm) personList.get(ndx);
    public void setPersonList(int ndx, PersonForm p) {
        personList.set(ndx, p);

3) Assuming you don't already know the size of your personList, your
reset method
will initialize it and create the empty Person objects to fill with the

    public void reset(ActionMapping mapping, HttpServletRequest request)

        this.personList = new ArrayList();

        String num = request.getParameter("personListLength");
        try {
            if (num != null) {
                int len = Integer.parseInt(num);
                for (int i = 0; i < len; i++)
                    this.personList.add(new PersonForm());
        } catch (NumberFormatException e) {

This assumes the prep action that entered the jsp figured out the size
of the list
and set it into a hidden in the jsp in a field named personListLength.


-----Original Message-----
From: Sashi Ravipati []
Sent: Wednesday, June 11, 2003 1:19 PM
Subject: what setters do i implement in an indexed tag --NewBiequestion

Can some body help in as how to define get and set methods when we use
indexed tags.


<logic:iterate id="person" name="myFormBean" property="personList">
      <bean:write name="person" property="name"/>
      <html:hidden name="person" property="name" indexed="true"/>
      <html:text name="person" property="phoneNo" indexed="true"/>

What will be the get and set methods. 


To unsubscribe, e-mail:
For additional commands, e-mail:

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