You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cameron Ingram0 <ci...@tampabay.rr.com> on 2001/03/02 22:48:16 UTC

Interesting iteration problem

Hi All,

I am having some more problems with the iteration tag. I have a JSP that needs to have 3 tables displayed.  I have a bean, three of its properties 
are Vectors each holding some objects in them. When I added the first iteration tag I did not have a problem. Every thing displayed as it should.
When I added the second iteration tag the JSP threw an exception indicating that it could not find a getter for the property.  Well I know that nothing is wrong with the tag because I can remove the first table and the second table will display fine. I did come up with a work around and that was to 
add another instance of the bean to the session but renamed.  It's almost as if the second iteration tag is still looking in the orignal collection for the new property. Is there a way to reset the iterator so that I can use the same instance of the bean to iterate through, or is this a bug?

Ex  
/* Works fine  */
  <logic:iterate id="implementations" name="implementations" property="supportPersonnel">
  <tr>
    /* out put some information from the property */
  </tr>
 </logic:iterate>

/* This one will cause an exception to occur, No Getter method for the contactPeople property. Almost seems as if it is looking in
 the supportPersonnel property for the contactPeople */

<logic:iterate id="implementations" name="implementations" property="contactPeople">
  <tr>
    /* out put some information from the property */
  </tr>
 </logic:iterate>

  /* added a new instance of the same bean but renamed to the session, will not cause an exception */
  <logic:iterate id="impl" name="impl" property="contactPeople" >
  <tr>
   /* out put some information from the property. */
  </tr>
 </logic:iterate>

Thanks in advance!! Cameron Ingram :)




Re: Interesting iteration problem

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Cameron Ingram0 wrote:

> Hi All,
>
> I am having some more problems with the iteration tag. I have a JSP
> that needs to have 3 tables displayed.  I have a bean, three of its
> properties
> are Vectors each holding some objects in them. When I added the first
> iteration tag I did not have a problem. Every thing displayed as it
> should.
> When I added the second iteration tag the JSP threw an exception
> indicating that it could not find a getter for the property.  Well I
> know that nothing is wrong with the tag because I can remove the first
> table and the second table will display fine. I did come up with a
> work around and that was to
> add another instance of the bean to the session but renamed.  It's
> almost as if the second iteration tag is still looking in the orignal
> collection for the new property. Is there a way to reset the iterator
> so that I can use the same instance of the bean to iterate through, or
> is this a bug?
>
> Ex
> /* Works fine  */
>   <logic:iterate id="implementations" name="implementations"
> property="supportPersonnel">
>   <tr>
>     /* out put some information from the property */
>   </tr>
>  </logic:iterate>
>
> /* This one will cause an exception to occur, No Getter method for the
> contactPeople property. Almost seems as if it is looking in
>  the supportPersonnel property for the contactPeople */
>
> <logic:iterate id="implementations" name="implementations"
> property="contactPeople">
>   <tr>
>     /* out put some information from the property */
>   </tr>
>  </logic:iterate>
>
>   /* added a new instance of the same bean but renamed to the session,
> will not cause an exception */
>   <logic:iterate id="impl" name="impl" property="contactPeople" >
>   <tr>
>    /* out put some information from the property. */
>   </tr>
>  </logic:iterate>
>
> Thanks in advance!! Cameron Ingram :)

There is a JSP-wide restriction (in the spec) that you cannot have two
or more tags with the same "id" value.  It looks like you might have
been violating this constraint.

Craig McClanahan