In an attempt to use an iterate tag, my jsp engine has been unable to find the
getters and setters of the corresponding bean.  The jsp code looks like this
(copied from one of your online examples):

<% int count=0; %>
          <struts:iterate id="row" name="test" property="collection" >
                     <tr BGCOLOR='<%= (count++ % 2==0 ?"#FFFFAA":"#EEEEEE") %>'
>
                          <td>&nbsp;<%= count %>&nbsp;</td>
                     <struts:iterate id="item" collection="<%= row %>" >
                               <td nowrap align=MIDDLE
>&nbsp;<%=(item).toString() %>&nbsp;</td>
               </struts:iterate>
                    </tr>
           </struts:iterate>

at the top of the code(previous to the <struts:iterate> stuff) I attempt to
instantiate the bean and call a setter just to see if contact is being made:

          <% Test t = new Test();
            t.init();
           pageContext.setAttribute("test", t); %>

Instead Struts throws this exception:

          Error: No method named "init" was found in type "Test".

The same error occurs with
           t.setCollection and t.getCollection

The bean looks like the followingV---what have I done wrong?
                          V
                                               V
public class Test
{
    private Collection collection;
    String string1;

    public Test() {

    }

    public void init()
    {
        Vector becomeCollection = new Vector();


        for (int i=0;i<5;i++)
        {
            string1= new String("string"+i);
            becomeCollection.addElement(string1);
        }

        collection=becomeCollection;



    }

    public Collection getCollection()
    {
        return this.collection;
    }

    public void setCollection(Collection collection)
    {
         this.collection=collection;
    }

}



Reply via email to