I'm having trouble getting the setter methods of an indexed property of my
formbean to work (despite some postings on this list). It's driving me nuts.

So what I'm trying to do is use a String property of my formbean (actually a
List of Strings) as an indexed property.

=======
JSP
=======
<html:form action="/editCart.do" >

<TABLE border="1" borderwidth="1" cellspacing="0">

<logic:iterate id="cartItem" name="<%= Constants.KEY_CART %>"
type="com.webtothemax.shop.common.CartItem" property="cartItems">

<TR>
    <TD><bean:write name="cartItem" property="product.name" /></TD>
    <TD><bean:write name="cartItem" property="product.price" /></TD>
 :
 :
    <TD><html:text property="test" indexed="true" /></TD>
 :
 :
-----
Note that the last field references the formbean (at least it should since
"name=" is omittted). Note also that the iteration is not over the formbean
(property).


=============
Struts-config
=============

 <action    path="/addToCart"
               type="com.webtothemax.shop.actions.AddToCartAction"
               name="editCartForm"
               scope="request"
               validate="false" >
        <forward name="success" path="/WEB-INF/jsp/editCart.jsp" />
        <forward name="error" path="/WEB-INF/jsp/showError.jsp" />
    </action>

    <action    path="/editCart"
               type="com.webtothemax.shop.actions.EditCartAction"
               name="editCartForm"
               scope="request"
               validate="false"
               input= "/WEB-INF/jsp/editCart.jsp" >
        <forward name="success" path="/WEB-INF/jsp/editCart.jsp" />
        <forward name="error" path="/WEB-INF/jsp/showError.jsp" />
    </action>

-----
AddToCartAction adds the product and prepopulates the formbean.

==============
Form bean editCartForm
==============

public class EditCartForm extends ActionForm {

 :
 :

    private ArrayList testList = new ArrayList();

    public EditCartForm() {}

 :
 :
 :

    public String getTest(int index) {
        return (String) testList.get(index);
    }

    public void setTest(int index, String test) {
        testList.set(index, test);
    }

    public ArrayList getTestList() {
        return testList;
    }

    public void setTestList( ArrayList testList ) {
        this.testList = testList;
    }
}
-----
I got the idea for set/getTestList from this mailinglist.

============
The result:
============
Error: 500
Location: /WEB-INF/jsp/editCart.jsp
Internal Servlet Error:
javax.servlet.ServletException: No getter method for property test of bean
editCartForm
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:459)
at
WEB_0002dINF.jsp._0002fWEB_0002dINF_0002fjsp_0002feditCart_0002ejspeditCart_
jsp_7._jspService(_0002fWEB_0002dINF_0002fjsp_0002feditCart_0002ejspeditCart
_jsp_7.java:690)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)

 :
 :

Root cause:
javax.servlet.jsp.JspException: No getter method for property test of bean
editCartForm
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:519)
at
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:190)
at
WEB_0002dINF.jsp._0002fWEB_0002dINF_0002fjsp_0002feditCart_0002ejspeditCart_
jsp_7._jspService(_0002fWEB_0002dINF_0002fjsp_0002feditCart_0002ejspeditCart
_jsp_7.java:534)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)

========================

What am I doing wrong? Any help appreciated


Marcel Maré

WebToTheMax
[EMAIL PROTECTED]


Reply via email to