Re: Can't get setter method(s) for indexed property right. Pleeze help
Marcel, I walked through code example submitted by Warwick Boote to get past issues/concepts with setters for indexed properties. The only change I made was to add a second field to the form. So, if your list is named properties, you would have second field on the form called "property" also. My property set method added an item to the properties vector (if it did not already exist on the vector)... I don't know if this is the best way to do it, but it worked. Brian Here's the message Warwick posted: Here is a hacked version of the code posted by David Hay previously. The code here will compile and run - a Vector is populated then displayed. After a post, the vector is retrieved from the form and then System.out is used to show its size. This should help others that are having problems with indexed tags. You'll need to point your browser to somthing that looks like http://localhost/struts/ShowParameters.do once you've copied all the files into the correct locations. There were two issues with the way i was trying to do it, firstly it seems that unless the scope of the form is set to session (or not specified) it doesn't work and secondly because i was using a different id for the name in the logic:iterate / html:text tags (when i set them to "parameter" it worked). Waz. =) -Original Message- From: Warwick Boote [mailto:[EMAIL PROTECTED]] Sent: 24 July 2001 14:09 To: [EMAIL PROTECTED] Subject: what setters do i implement in an indexed tag ? I've created a page using indexed tags (neat stuff!). Here is what is currently working for me: o If i populate the form's vector, values from that vector are displayed in the jsp Here is what it not working: o when the form is posted back, the vector is null (in the struts perform() method) I suspect i haven't implemented some sort of setter within the form but i can't find an example as to what method should be implemented. I've tried ArrayList and using parameterList instead with no different result. Thanks, Waz. =) Here are some code snippits for help: ---jsp--- ---Form--- public class FieldsMapForm extends ActionForm { private String fileColCount; private java.util.Vector fieldMappings = new java.util.Vector(); private String action; public String getFileColCount() { return fileColCount; } public void setFileColCount(String newFileColCount) { fileColCount = newFileColCount; } public void setFieldMappings(java.util.Vector newFieldMappings) { fieldMappings = newFieldMappings; } public java.util.Vector getFieldMappings() { return fieldMappings; } public FieldMapping getParameter(int index) { return (FieldMapping)fieldMappings.elementAt(index); } public void setAction(String newAction) { action = newAction; } public String getAction() { return action; } public void reset(ActionMapping mapping, HttpServletRequest request) { fileColCount = null; fieldMappings = new java.util.Vector(); action = null; } } ---The vector contains these:--- public class FieldMapping implements Serializable { private Integer fieldNumber; private String attributeCode; public void setFieldNumber(Integer newFieldNumber) { fieldNumber = newFieldNumber; } public Integer getFieldNumber() { return fieldNumber; } public void setAttributeCode(String newAttributeCode) { attributeCode = newAttributeCode; } public String getAttributeCode() { return attributeCode; } } <> (See attached file: indexed_eg_rwb.zip) Marcel Maré emax.com>cc: Subject: Can't get setter method(s) for indexed property right. 08/08/2001 Pleeze help 04:46 PM Please respond to struts-user 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 S
Can't get setter method(s) for indexed property right. Pleeze help
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 === : : : : - 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 = - 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]
Can't get setter method(s) for indexed property right. Pleeze help
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 === : : : : - 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 = - 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]
Can't get setter method(s) for indexed property right. Pleeze help
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 === : : : : - 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 = - 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]