You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Yee <ry...@yahoo.com> on 2002/12/19 18:11:18 UTC
Re: beanutils.populate with formbeans and vectors
Michael,
You need to put the methods that I sent in the
FormBean class and not your Vector subclass. You
really don't need to subclass the Vector.
ex.
public class MyForm extends ActionForm
{
private Vector myFoos = new Vector();
/**
* getter for indexed property in myFoos
*/
public Object getFoo(int index) {
if (index >= myFoos.size())
return "";
return myFoos.get(index);
}
/**
* setter for indexed property in myFoos
*/
public void setFoo(int index, Object value) {
int size=myFoos.size();
if (index >= size) {
for(int i=size; i<=index; i++) {
myFoos.add("");
}
}
myFoos.set(index,value);
}
}
-Richard
> Does anybody have an idea, where this exception is
> from. I�m still working on it......
>
> Thaks a lot, Michael
> --
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: beanutils.populate with formbeans and vectors
Posted by Michael Olszynski <m....@proway.de>.
.....
and if I also change the type of my indexed getter like this:
/**
* getter for indexed property in myFoos
*/
public TimeProofTableBean getTimeProofList(int index) {
if (index >= timeProofList.size())
return new TimeProofTableBean();
return (TimeProofTableBean) timeProofList.get(index);
}
I get following error:
18:49:56,141 ERROR [Engine] StandardWrapperValve[action]: Servlet.service()
for
servlet action threw exception
javax.servlet.ServletException: BeanUtils.populate
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:980)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProc
essor.java:779)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:246)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:129
2)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:260)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve
.java:246)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
the same error I had before!
--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
----- Original Message -----
From: "Michael Olszynski" <m....@proway.de>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, December 19, 2002 6:49 PM
Subject: Re: beanutils.populate with formbeans and vectors
> Hi Richard,
>
> thanks again for your quick reply. I thought I need to subclass Vector,
> because I don´t save plain Strings in my Vector, I save Beans in it. So
> therefore I thought I need to have a polymorhism to save myself the work
to
> write always indexed setters and getters . But anyway, I put the code you
> wrote me in my bean, and I still get errors. I give you a small snippet of
> my code (I tried to remove everything unnecessary) and I also attach the
> errormessage after the samplecode. I´d really appreciate if you could look
> at it for a short moment. Thanks a lot
>
> Take care Michael
>
> ****************************************************
> public class TimeProofFormBean extends ActionForm {
>
> private Vector timeProofList = new Vector();
>
> public Vector getTimeProofList() {
> return this.timeProofList;
> }
>
> public void setTimeProofList( Vector v ) {
> this.timeProofList = v;
> }
>
>
> /**
> * getter for indexed property in myFoos
> */
> public Object getTimeProofList(int index) {
> if (index >= timeProofList.size())
> return new TimeProofTableBean();
> return timeProofList.get(index);
> }
>
> /**
> * setter for indexed property in myFoos
> */
> public void setTimeProofList(int index, Object value) {
> int size=timeProofList.size();
> if (index >= size) {
> for(int i=size; i<=index; i++) {
> timeProofList.add(new TimeProofTableBean());
> }
> }
> timeProofList.set(index,value);
> }
>
>
> }
> **********************************************************
> jsp page:
> <logic:iterate id="timeProofList" indexId="listIdx" name="timeProofForm"
> property="timeProofList">
> <tr>
> <td> <html:text name="timeProofList" property="fromHour" size="2"
> maxlength="2" indexed="true"/>:
> <html:text name="timeProofList" property="fromMinute" size="2"
> maxlength="2" indexed="true"/> </td>
> </tr>
> </logic:iterate>
> ****************************************************************
>
> 18:35:35,684 ERROR [Engine]
> ApplicationDispatcher[/Zeiterfassung_Applikation] Se
> rvlet.service() for servlet jsp threw exception
> org.apache.jasper.JasperException: No getter method for property
> timeProofList o
> f bean timeProofForm
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> .java:248)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> 89)
> at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> atcher.java:684)
> at
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> ispatcher.java:575)
> at
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> patcher.java:498)
> at
> org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> .java:820)
> at
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> a:395)
> at
> org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191)
> at
> org.apache.jsp.template_jsp._jspx_meth_template_get_4(template_jsp.ja
> va:221)
> at
> org.apache.jsp.template_jsp._jspx_meth_html_html_0(template_jsp.java:
> 118)
> at org.apache.jsp.template_jsp._jspService(template_jsp.java:62)
> at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> .java:204)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> 89)
> at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> atcher.java:684)
> at
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> ispatcher.java:575)
> at
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> patcher.java:498)
> at
> org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> .java:820)
> at
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> --
> Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
> Entwickler!
> ----- Original Message -----
> From: "Richard Yee" <ry...@yahoo.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, December 19, 2002 6:11 PM
> Subject: Re: beanutils.populate with formbeans and vectors
>
>
> > Michael,
> > You need to put the methods that I sent in the
> > FormBean class and not your Vector subclass. You
> > really don't need to subclass the Vector.
> >
> >
> > ex.
> >
> > public class MyForm extends ActionForm
> > {
> > private Vector myFoos = new Vector();
> >
> > /**
> > * getter for indexed property in myFoos
> > */
> > public Object getFoo(int index) {
> > if (index >= myFoos.size())
> > return "";
> > return myFoos.get(index);
> > }
> >
> > /**
> > * setter for indexed property in myFoos
> > */
> > public void setFoo(int index, Object value) {
> > int size=myFoos.size();
> > if (index >= size) {
> > for(int i=size; i<=index; i++) {
> > myFoos.add("");
> > }
> > }
> > myFoos.set(index,value);
> > }
> >
> >
> > }
> >
> >
> > -Richard
> >
> > > Does anybody have an idea, where this exception is
> > > from. I´m still working on it......
> > >
> > > Thaks a lot, Michael
> > > --
> >
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: beanutils.populate with formbeans and vectors
Posted by Michael Olszynski <m....@proway.de>.
Hi Richard,
thanks a lot for your code. This works also fine with me (I tried that
before) But if you switch from
<bean:write name="myObject" property="address"/>
to
<html:text name="myObject" property="address"/>
and then submit these values to antoher form, or you change it and submit it
to the same form, I get the beanutils. populate error. The output is always
fine, but the input is a mess.
I hope you also have a solution for this!
Thanks a lot
Michael
--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
----- Original Message -----
From: "Richard Yee" <ry...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, December 19, 2002 10:03 PM
Subject: Re: beanutils.populate with formbeans and vectors
> Michael,
> This code works:
>
> TestActionForm.java
> -------------------
> package com.test;
>
> import java.util.*;
> import org.apache.struts.action.*;
>
> public class TestActionForm extends ActionForm
> {
> private ArrayList myItems = new ArrayList();
> public TestActionForm()
> {
> myItems.add(new MyObject("John Doe", "1 Main
> St."));
> myItems.add(new MyObject("Jane Doe", "2 Main
> St."));
> }
>
> public Collection getMyItems() {
> return myItems;
> }
>
> public void setMyItems(ArrayList items) {
> myItems = items;
> }
>
> public Object getItem(int index) {
> if (index >= myItems.size())
> return new MyObject();
> return myItems.get(index);
>
> }
>
> /**
> * setter for indexed property in myItems
> */
> public void setMyItem(int index, Object value) {
> int size=myItems.size();
> if (index >= size) {
> for(int i=size; i<=index; i++) {
> myItems.add(new MyObject());
> }
> }
> myItems.set(index,value);
> }
> }
>
> TestAction.java
> ---------------
> package com.test;
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
> import org.apache.struts.action.ActionError;
> import org.apache.struts.action.ActionErrors;
> import java.io.IOException;
> import java.util.Collection;
> import java.util.Vector;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.http.HttpSession;
>
> public class TestAction extends Action
> {
> /**
> * This is the main action called from the Struts
> framework.
> * @param mapping The ActionMapping used to select
> this instance.
> * @param form The optional ActionForm bean for this
> request.
> * @param request The HTTP Request we are
> processing.
> * @param response The HTTP Response we are
> processing.
> */
> public ActionForward perform(ActionMapping mapping,
> ActionForm form, HttpServletRequest request,
> HttpServletResponse response) throws IOException,
> ServletException
> {
> TestActionForm testForm = (TestActionForm) form;
> System.out.println("TestAction.perform()");
> return mapping.findForward("success");
> }
> }
>
> MyObject.java
> -------------
> package com.test;
>
> import javax.servlet.http.HttpServletRequest;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionError;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.action.ActionMapping;
> import org.apache.struts.upload.FormFile;
>
> public class MyObject
> {
>
> private String name = null;
> private String address = null;
>
> public MyObject() {
> name = "";
> address = "";
> }
>
> public MyObject(String _name, String _address)
> {
> name = _name;
> address = _address;
> }
>
> /**
> * getter method for name
> */
> public String getName() {
> return (name);
> }
> /**
> * setter method for name
> * @param - name;
> */
> public void setName(String _name) {
> name = _name;
> }
>
> /**
> * getter method for address
> */
> public String getAddress() {
> return (address);
> }
> /**
> * setter method for address
> * @param - address;
> */
> public void setAddress(String _address) {
> address = _address;
> }
>
> public String toString() {
> return name + ", " + address + "/n";
> }
> }
>
>
>
> In the JSP page
>
> <logic:iterate name="testActionForm"
> property="myItems" id="myObject">
> in iterate <bean:write name="myObject" property="name"
> /> <bean:write name="myObject" property="address"
> /><br>
> </logic:iterate>
>
> The output:
> in iterate John Doe 1 Main St.
> in iterate Jane Doe 2 Main St.
>
>
> Hope that helps,
>
> Richard
>
>
>
>
>
>
> --- Michael Olszynski <m....@proway.de> wrote:
> > I do it like this:
> >
> > <logic:iterate id="timeProofList" indexId="listIdx"
> > name="timeProofForm"
> > property="timeProofList">
> > <tr>
> > <td> <html:text name="timeProofList"
> > property="fromHour" indexed="true"/>:
> > <html:text name="timeProofList"
> > property="fromMinute"
> > indexed="true"/> </td>
> > </tr>
> > </logic:iterate>
> >
> > --
> > Fehlerfreie Software wirkt weniger komplex und
> > diskreditiert damit den
> > Entwickler!
> > ----- Original Message -----
> > From: "Richard Yee" <ry...@yahoo.com>
> > To: "Struts Users Mailing List"
> > <st...@jakarta.apache.org>
> > Sent: Thursday, December 19, 2002 7:16 PM
> > Subject: Re: beanutils.populate with formbeans and
> > vectors
> >
> >
> > > Michael,
> > > How are you accessing the indexed property in the
> > JSP?
> > >
> > > -Richard
> > >
> > > --- Michael Olszynski <m....@proway.de>
> > wrote:
> > > > Hi Richard,
> > > >
> > > > thanks again for your quick reply. I thought I
> > need
> > > > to subclass Vector,
> > > > because I don´t save plain Strings in my Vector,
> > I
> > > > save Beans in it. So
> > > > therefore I thought I need to have a polymorhism
> > to
> > > > save myself the work to
> > > > write always indexed setters and getters . But
> > > > anyway, I put the code you
> > > > wrote me in my bean, and I still get errors. I
> > give
> > > > you a small snippet of
> > > > my code (I tried to remove everything
> > unnecessary)
> > > > and I also attach the
> > > > errormessage after the samplecode. I´d really
> > > > appreciate if you could look
> > > > at it for a short moment. Thanks a lot
> > > >
> > > > Take care Michael
> > > >
> > > >
> > ****************************************************
> > > > public class TimeProofFormBean extends
> > ActionForm {
> > > >
> > > > private Vector timeProofList = new Vector();
> > > >
> > > > public Vector getTimeProofList() {
> > > > return this.timeProofList;
> > > > }
> > > >
> > > > public void setTimeProofList( Vector v ) {
> > > > this.timeProofList = v;
> > > > }
> > > >
> > > >
> > > > /**
> > > > * getter for indexed property in myFoos
> > > > */
> > > > public Object getTimeProofList(int index) {
> > > > if (index >= timeProofList.size())
> > > > return new TimeProofTableBean();
> > > > return timeProofList.get(index);
> > > > }
> > > >
> > > > /**
> > > > * setter for indexed property in myFoos
> > > > */
> > > > public void setTimeProofList(int index,
> > Object
> > > > value) {
> > > > int size=timeProofList.size();
> > > > if (index >= size) {
> > > > for(int i=size; i<=index; i++) {
> > > > timeProofList.add(new
> > > > TimeProofTableBean());
> > > > }
> > > > }
> > > > timeProofList.set(index,value);
> > > > }
> > > >
> > > >
> > > > }
> > > >
> > >
> >
> **********************************************************
> > > > jsp page:
> > > > <logic:iterate id="timeProofList"
> > indexId="listIdx"
> > > > name="timeProofForm"
> > > > property="timeProofList">
> > > > <tr>
> > > > <td> <html:text name="timeProofList"
> > > > property="fromHour" size="2"
> > > > maxlength="2" indexed="true"/>:
> > > > <html:text name="timeProofList"
> > > > property="fromMinute" size="2"
> > > > maxlength="2" indexed="true"/> </td>
> > > > </tr>
> > > > </logic:iterate>
> > > >
> > >
> >
> ****************************************************************
> > > >
> > > > 18:35:35,684 ERROR [Engine]
> > > >
> > ApplicationDispatcher[/Zeiterfassung_Applikation] Se
> > > > rvlet.service() for servlet jsp threw exception
> > > > org.apache.jasper.JasperException: No getter
> > method
> > > > for property
> > > > timeProofList o
> > > > f bean timeProofForm
> > > > at
> > > >
> > >
> >
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> > > > .java:248)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> > > > 89)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> > > > at
> > > >
> > >
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > > > at
> > > >
> > >
> >
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> > > > atcher.java:684)
> > > > at
> > > >
> > >
> >
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> > > > ispatcher.java:575)
> > > > at
> > > >
> > >
> >
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> > > > patcher.java:498)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> > > > .java:820)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> > > > a:395)
> > > > at
> > > >
> > >
> >
> org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191)
> > > > at
> > > >
> > >
> >
> org.apache.jsp.template_jsp._jspx_meth_template_get_4(template_jsp.ja
> > > > va:221)
> > > > at
> > > >
> > >
> >
> org.apache.jsp.template_jsp._jspx_meth_html_html_0(template_jsp.java:
> > > > 118)
> > > > at
> > > >
> > >
> >
> org.apache.jsp.template_jsp._jspService(template_jsp.java:62)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
> > > > at
> > > >
> > >
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >
> === message truncated ===
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: beanutils.populate with formbeans and vectors
Posted by Michael Olszynski <m....@proway.de>.
Hi Richard
you have following methods in your Action form (see below)
shouldn´t
public Object getItem(int index) {
be called
public Object getMyItems(int index) {
and
public void setMyItem(int index, Object value) {
be called
public void setMyItems(int index, Object value) {
?????????????????
Are these methods ever called from struts? How are the naming conventions?
Thanks Michael
>
> TestActionForm.java
> -------------------
> package com.test;
>
> import java.util.*;
> import org.apache.struts.action.*;
>
> public class TestActionForm extends ActionForm
> {
> private ArrayList myItems = new ArrayList();
> public TestActionForm()
> {
> myItems.add(new MyObject("John Doe", "1 Main
> St."));
> myItems.add(new MyObject("Jane Doe", "2 Main
> St."));
> }
>
> public Collection getMyItems() {
> return myItems;
> }
>
> public void setMyItems(ArrayList items) {
> myItems = items;
> }
>
> public Object getItem(int index) {
> if (index >= myItems.size())
> return new MyObject();
> return myItems.get(index);
>
> }
>
> /**
> * setter for indexed property in myItems
> */
> public void setMyItem(int index, Object value) {
> int size=myItems.size();
> if (index >= size) {
> for(int i=size; i<=index; i++) {
> myItems.add(new MyObject());
> }
> }
> myItems.set(index,value);
> }
> }
>
> TestAction.java
> ---------------
> package com.test;
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
> import org.apache.struts.action.ActionError;
> import org.apache.struts.action.ActionErrors;
> import java.io.IOException;
> import java.util.Collection;
> import java.util.Vector;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.http.HttpSession;
>
> public class TestAction extends Action
> {
> /**
> * This is the main action called from the Struts
> framework.
> * @param mapping The ActionMapping used to select
> this instance.
> * @param form The optional ActionForm bean for this
> request.
> * @param request The HTTP Request we are
> processing.
> * @param response The HTTP Response we are
> processing.
> */
> public ActionForward perform(ActionMapping mapping,
> ActionForm form, HttpServletRequest request,
> HttpServletResponse response) throws IOException,
> ServletException
> {
> TestActionForm testForm = (TestActionForm) form;
> System.out.println("TestAction.perform()");
> return mapping.findForward("success");
> }
> }
>
> MyObject.java
> -------------
> package com.test;
>
> import javax.servlet.http.HttpServletRequest;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionError;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.action.ActionMapping;
> import org.apache.struts.upload.FormFile;
>
> public class MyObject
> {
>
> private String name = null;
> private String address = null;
>
> public MyObject() {
> name = "";
> address = "";
> }
>
> public MyObject(String _name, String _address)
> {
> name = _name;
> address = _address;
> }
>
> /**
> * getter method for name
> */
> public String getName() {
> return (name);
> }
> /**
> * setter method for name
> * @param - name;
> */
> public void setName(String _name) {
> name = _name;
> }
>
> /**
> * getter method for address
> */
> public String getAddress() {
> return (address);
> }
> /**
> * setter method for address
> * @param - address;
> */
> public void setAddress(String _address) {
> address = _address;
> }
>
> public String toString() {
> return name + ", " + address + "/n";
> }
> }
>
>
>
> In the JSP page
>
> <logic:iterate name="testActionForm"
> property="myItems" id="myObject">
> in iterate <bean:write name="myObject" property="name"
> /> <bean:write name="myObject" property="address"
> /><br>
> </logic:iterate>
>
> The output:
> in iterate John Doe 1 Main St.
> in iterate Jane Doe 2 Main St.
>
>
> Hope that helps,
>
> Richard
>
>
>
>
>
>
> --- Michael Olszynski <m....@proway.de> wrote:
> > I do it like this:
> >
> > <logic:iterate id="timeProofList" indexId="listIdx"
> > name="timeProofForm"
> > property="timeProofList">
> > <tr>
> > <td> <html:text name="timeProofList"
> > property="fromHour" indexed="true"/>:
> > <html:text name="timeProofList"
> > property="fromMinute"
> > indexed="true"/> </td>
> > </tr>
> > </logic:iterate>
> >
> > --
> > Fehlerfreie Software wirkt weniger komplex und
> > diskreditiert damit den
> > Entwickler!
> > ----- Original Message -----
> > From: "Richard Yee" <ry...@yahoo.com>
> > To: "Struts Users Mailing List"
> > <st...@jakarta.apache.org>
> > Sent: Thursday, December 19, 2002 7:16 PM
> > Subject: Re: beanutils.populate with formbeans and
> > vectors
> >
> >
> > > Michael,
> > > How are you accessing the indexed property in the
> > JSP?
> > >
> > > -Richard
> > >
> > > --- Michael Olszynski <m....@proway.de>
> > wrote:
> > > > Hi Richard,
> > > >
> > > > thanks again for your quick reply. I thought I
> > need
> > > > to subclass Vector,
> > > > because I don´t save plain Strings in my Vector,
> > I
> > > > save Beans in it. So
> > > > therefore I thought I need to have a polymorhism
> > to
> > > > save myself the work to
> > > > write always indexed setters and getters . But
> > > > anyway, I put the code you
> > > > wrote me in my bean, and I still get errors. I
> > give
> > > > you a small snippet of
> > > > my code (I tried to remove everything
> > unnecessary)
> > > > and I also attach the
> > > > errormessage after the samplecode. I´d really
> > > > appreciate if you could look
> > > > at it for a short moment. Thanks a lot
> > > >
> > > > Take care Michael
> > > >
> > > >
> > ****************************************************
> > > > public class TimeProofFormBean extends
> > ActionForm {
> > > >
> > > > private Vector timeProofList = new Vector();
> > > >
> > > > public Vector getTimeProofList() {
> > > > return this.timeProofList;
> > > > }
> > > >
> > > > public void setTimeProofList( Vector v ) {
> > > > this.timeProofList = v;
> > > > }
> > > >
> > > >
> > > > /**
> > > > * getter for indexed property in myFoos
> > > > */
> > > > public Object getTimeProofList(int index) {
> > > > if (index >= timeProofList.size())
> > > > return new TimeProofTableBean();
> > > > return timeProofList.get(index);
> > > > }
> > > >
> > > > /**
> > > > * setter for indexed property in myFoos
> > > > */
> > > > public void setTimeProofList(int index,
> > Object
> > > > value) {
> > > > int size=timeProofList.size();
> > > > if (index >= size) {
> > > > for(int i=size; i<=index; i++) {
> > > > timeProofList.add(new
> > > > TimeProofTableBean());
> > > > }
> > > > }
> > > > timeProofList.set(index,value);
> > > > }
> > > >
> > > >
> > > > }
> > > >
> > >
> >
> **********************************************************
> > > > jsp page:
> > > > <logic:iterate id="timeProofList"
> > indexId="listIdx"
> > > > name="timeProofForm"
> > > > property="timeProofList">
> > > > <tr>
> > > > <td> <html:text name="timeProofList"
> > > > property="fromHour" size="2"
> > > > maxlength="2" indexed="true"/>:
> > > > <html:text name="timeProofList"
> > > > property="fromMinute" size="2"
> > > > maxlength="2" indexed="true"/> </td>
> > > > </tr>
> > > > </logic:iterate>
> > > >
> > >
> >
> ****************************************************************
> > > >
> > > > 18:35:35,684 ERROR [Engine]
> > > >
> > ApplicationDispatcher[/Zeiterfassung_Applikation] Se
> > > > rvlet.service() for servlet jsp threw exception
> > > > org.apache.jasper.JasperException: No getter
> > method
> > > > for property
> > > > timeProofList o
> > > > f bean timeProofForm
> > > > at
> > > >
> > >
> >
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> > > > .java:248)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> > > > 89)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> > > > at
> > > >
> > >
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > > > at
> > > >
> > >
> >
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> > > > atcher.java:684)
> > > > at
> > > >
> > >
> >
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> > > > ispatcher.java:575)
> > > > at
> > > >
> > >
> >
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> > > > patcher.java:498)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> > > > .java:820)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> > > > a:395)
> > > > at
> > > >
> > >
> >
> org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191)
> > > > at
> > > >
> > >
> >
> org.apache.jsp.template_jsp._jspx_meth_template_get_4(template_jsp.ja
> > > > va:221)
> > > > at
> > > >
> > >
> >
> org.apache.jsp.template_jsp._jspx_meth_html_html_0(template_jsp.java:
> > > > 118)
> > > > at
> > > >
> > >
> >
> org.apache.jsp.template_jsp._jspService(template_jsp.java:62)
> > > > at
> > > >
> > >
> >
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
> > > > at
> > > >
> > >
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >
> === message truncated ===
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
BeanUtil.copyProperties problem with casted ActionForm
Posted by adam kramer <ad...@monkey.org>.
I keep getting an error in my Action where I am using
BeanUtils.copyProperties to copy from a ActionForm to a bean like so:
GrantForm grantForm = (GrantForm) form;
BeanUtils.copyProperties(grant, grantForm);
and i get the exception:
java.lang.IllegalArgumentException: argument type mismatch
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1669)
The weird thing is I don't get the error when I try:
GrantForm grantForm = new GrantForm();
BeanUtils.copyProperties(grant, grantForm);
So it only occurs when I cast the passed in form parameter to the right
form type.
Has anyone else had similar problems? I can say that my form does have
ArrayLists that my bean does not have but they are completely different
attribute names.
-adam k.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: beanutils.populate with formbeans and vectors
Posted by Richard Yee <ry...@yahoo.com>.
Michael,
This code works:
TestActionForm.java
-------------------
package com.test;
import java.util.*;
import org.apache.struts.action.*;
public class TestActionForm extends ActionForm
{
private ArrayList myItems = new ArrayList();
public TestActionForm()
{
myItems.add(new MyObject("John Doe", "1 Main
St."));
myItems.add(new MyObject("Jane Doe", "2 Main
St."));
}
public Collection getMyItems() {
return myItems;
}
public void setMyItems(ArrayList items) {
myItems = items;
}
public Object getItem(int index) {
if (index >= myItems.size())
return new MyObject();
return myItems.get(index);
}
/**
* setter for indexed property in myItems
*/
public void setMyItem(int index, Object value) {
int size=myItems.size();
if (index >= size) {
for(int i=size; i<=index; i++) {
myItems.add(new MyObject());
}
}
myItems.set(index,value);
}
}
TestAction.java
---------------
package com.test;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import java.io.IOException;
import java.util.Collection;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class TestAction extends Action
{
/**
* This is the main action called from the Struts
framework.
* @param mapping The ActionMapping used to select
this instance.
* @param form The optional ActionForm bean for this
request.
* @param request The HTTP Request we are
processing.
* @param response The HTTP Response we are
processing.
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException,
ServletException
{
TestActionForm testForm = (TestActionForm) form;
System.out.println("TestAction.perform()");
return mapping.findForward("success");
}
}
MyObject.java
-------------
package com.test;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class MyObject
{
private String name = null;
private String address = null;
public MyObject() {
name = "";
address = "";
}
public MyObject(String _name, String _address)
{
name = _name;
address = _address;
}
/**
* getter method for name
*/
public String getName() {
return (name);
}
/**
* setter method for name
* @param - name;
*/
public void setName(String _name) {
name = _name;
}
/**
* getter method for address
*/
public String getAddress() {
return (address);
}
/**
* setter method for address
* @param - address;
*/
public void setAddress(String _address) {
address = _address;
}
public String toString() {
return name + ", " + address + "/n";
}
}
In the JSP page
<logic:iterate name="testActionForm"
property="myItems" id="myObject">
in iterate <bean:write name="myObject" property="name"
/> <bean:write name="myObject" property="address"
/><br>
</logic:iterate>
The output:
in iterate John Doe 1 Main St.
in iterate Jane Doe 2 Main St.
Hope that helps,
Richard
--- Michael Olszynski <m....@proway.de> wrote:
> I do it like this:
>
> <logic:iterate id="timeProofList" indexId="listIdx"
> name="timeProofForm"
> property="timeProofList">
> <tr>
> <td> <html:text name="timeProofList"
> property="fromHour" indexed="true"/>:
> <html:text name="timeProofList"
> property="fromMinute"
> indexed="true"/> </td>
> </tr>
> </logic:iterate>
>
> --
> Fehlerfreie Software wirkt weniger komplex und
> diskreditiert damit den
> Entwickler!
> ----- Original Message -----
> From: "Richard Yee" <ry...@yahoo.com>
> To: "Struts Users Mailing List"
> <st...@jakarta.apache.org>
> Sent: Thursday, December 19, 2002 7:16 PM
> Subject: Re: beanutils.populate with formbeans and
> vectors
>
>
> > Michael,
> > How are you accessing the indexed property in the
> JSP?
> >
> > -Richard
> >
> > --- Michael Olszynski <m....@proway.de>
> wrote:
> > > Hi Richard,
> > >
> > > thanks again for your quick reply. I thought I
> need
> > > to subclass Vector,
> > > because I don�t save plain Strings in my Vector,
> I
> > > save Beans in it. So
> > > therefore I thought I need to have a polymorhism
> to
> > > save myself the work to
> > > write always indexed setters and getters . But
> > > anyway, I put the code you
> > > wrote me in my bean, and I still get errors. I
> give
> > > you a small snippet of
> > > my code (I tried to remove everything
> unnecessary)
> > > and I also attach the
> > > errormessage after the samplecode. I�d really
> > > appreciate if you could look
> > > at it for a short moment. Thanks a lot
> > >
> > > Take care Michael
> > >
> > >
> ****************************************************
> > > public class TimeProofFormBean extends
> ActionForm {
> > >
> > > private Vector timeProofList = new Vector();
> > >
> > > public Vector getTimeProofList() {
> > > return this.timeProofList;
> > > }
> > >
> > > public void setTimeProofList( Vector v ) {
> > > this.timeProofList = v;
> > > }
> > >
> > >
> > > /**
> > > * getter for indexed property in myFoos
> > > */
> > > public Object getTimeProofList(int index) {
> > > if (index >= timeProofList.size())
> > > return new TimeProofTableBean();
> > > return timeProofList.get(index);
> > > }
> > >
> > > /**
> > > * setter for indexed property in myFoos
> > > */
> > > public void setTimeProofList(int index,
> Object
> > > value) {
> > > int size=timeProofList.size();
> > > if (index >= size) {
> > > for(int i=size; i<=index; i++) {
> > > timeProofList.add(new
> > > TimeProofTableBean());
> > > }
> > > }
> > > timeProofList.set(index,value);
> > > }
> > >
> > >
> > > }
> > >
> >
>
**********************************************************
> > > jsp page:
> > > <logic:iterate id="timeProofList"
> indexId="listIdx"
> > > name="timeProofForm"
> > > property="timeProofList">
> > > <tr>
> > > <td> <html:text name="timeProofList"
> > > property="fromHour" size="2"
> > > maxlength="2" indexed="true"/>:
> > > <html:text name="timeProofList"
> > > property="fromMinute" size="2"
> > > maxlength="2" indexed="true"/> </td>
> > > </tr>
> > > </logic:iterate>
> > >
> >
>
****************************************************************
> > >
> > > 18:35:35,684 ERROR [Engine]
> > >
> ApplicationDispatcher[/Zeiterfassung_Applikation] Se
> > > rvlet.service() for servlet jsp threw exception
> > > org.apache.jasper.JasperException: No getter
> method
> > > for property
> > > timeProofList o
> > > f bean timeProofForm
> > > at
> > >
> >
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> > > .java:248)
> > > at
> > >
> >
>
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> > > 89)
> > > at
> > >
> >
>
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> > > at
> > >
> >
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > > at
> > >
> >
>
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> > > atcher.java:684)
> > > at
> > >
> >
>
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> > > ispatcher.java:575)
> > > at
> > >
> >
>
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> > > patcher.java:498)
> > > at
> > >
> >
>
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> > > .java:820)
> > > at
> > >
> >
>
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> > > a:395)
> > > at
> > >
> >
>
org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191)
> > > at
> > >
> >
>
org.apache.jsp.template_jsp._jspx_meth_template_get_4(template_jsp.ja
> > > va:221)
> > > at
> > >
> >
>
org.apache.jsp.template_jsp._jspx_meth_html_html_0(template_jsp.java:
> > > 118)
> > > at
> > >
> >
>
org.apache.jsp.template_jsp._jspService(template_jsp.java:62)
> > > at
> > >
> >
>
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
> > > at
> > >
> >
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
=== message truncated ===
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: beanutils.populate with formbeans and vectors
Posted by Michael Olszynski <m....@proway.de>.
I do it like this:
<logic:iterate id="timeProofList" indexId="listIdx" name="timeProofForm"
property="timeProofList">
<tr>
<td> <html:text name="timeProofList" property="fromHour" indexed="true"/>:
<html:text name="timeProofList" property="fromMinute"
indexed="true"/> </td>
</tr>
</logic:iterate>
--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
----- Original Message -----
From: "Richard Yee" <ry...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, December 19, 2002 7:16 PM
Subject: Re: beanutils.populate with formbeans and vectors
> Michael,
> How are you accessing the indexed property in the JSP?
>
> -Richard
>
> --- Michael Olszynski <m....@proway.de> wrote:
> > Hi Richard,
> >
> > thanks again for your quick reply. I thought I need
> > to subclass Vector,
> > because I don´t save plain Strings in my Vector, I
> > save Beans in it. So
> > therefore I thought I need to have a polymorhism to
> > save myself the work to
> > write always indexed setters and getters . But
> > anyway, I put the code you
> > wrote me in my bean, and I still get errors. I give
> > you a small snippet of
> > my code (I tried to remove everything unnecessary)
> > and I also attach the
> > errormessage after the samplecode. I´d really
> > appreciate if you could look
> > at it for a short moment. Thanks a lot
> >
> > Take care Michael
> >
> > ****************************************************
> > public class TimeProofFormBean extends ActionForm {
> >
> > private Vector timeProofList = new Vector();
> >
> > public Vector getTimeProofList() {
> > return this.timeProofList;
> > }
> >
> > public void setTimeProofList( Vector v ) {
> > this.timeProofList = v;
> > }
> >
> >
> > /**
> > * getter for indexed property in myFoos
> > */
> > public Object getTimeProofList(int index) {
> > if (index >= timeProofList.size())
> > return new TimeProofTableBean();
> > return timeProofList.get(index);
> > }
> >
> > /**
> > * setter for indexed property in myFoos
> > */
> > public void setTimeProofList(int index, Object
> > value) {
> > int size=timeProofList.size();
> > if (index >= size) {
> > for(int i=size; i<=index; i++) {
> > timeProofList.add(new
> > TimeProofTableBean());
> > }
> > }
> > timeProofList.set(index,value);
> > }
> >
> >
> > }
> >
> **********************************************************
> > jsp page:
> > <logic:iterate id="timeProofList" indexId="listIdx"
> > name="timeProofForm"
> > property="timeProofList">
> > <tr>
> > <td> <html:text name="timeProofList"
> > property="fromHour" size="2"
> > maxlength="2" indexed="true"/>:
> > <html:text name="timeProofList"
> > property="fromMinute" size="2"
> > maxlength="2" indexed="true"/> </td>
> > </tr>
> > </logic:iterate>
> >
> ****************************************************************
> >
> > 18:35:35,684 ERROR [Engine]
> > ApplicationDispatcher[/Zeiterfassung_Applikation] Se
> > rvlet.service() for servlet jsp threw exception
> > org.apache.jasper.JasperException: No getter method
> > for property
> > timeProofList o
> > f bean timeProofForm
> > at
> >
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> > .java:248)
> > at
> >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> > 89)
> > at
> >
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> > at
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at
> >
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> > atcher.java:684)
> > at
> >
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> > ispatcher.java:575)
> > at
> >
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> > patcher.java:498)
> > at
> >
> org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> > .java:820)
> > at
> >
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> > a:395)
> > at
> >
> org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191)
> > at
> >
> org.apache.jsp.template_jsp._jspx_meth_template_get_4(template_jsp.ja
> > va:221)
> > at
> >
> org.apache.jsp.template_jsp._jspx_meth_html_html_0(template_jsp.java:
> > 118)
> > at
> >
> org.apache.jsp.template_jsp._jspService(template_jsp.java:62)
> > at
> >
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
> > at
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at
> >
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> > .java:204)
> > at
> >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> > 89)
> > at
> >
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> > at
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at
> >
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> > atcher.java:684)
> > at
> >
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> > ispatcher.java:575)
> > at
> >
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> > patcher.java:498)
> > at
> >
> org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> > .java:820)
> > at
> >
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> > --
> > Fehlerfreie Software wirkt weniger komplex und
> > diskreditiert damit den
> > Entwickler!
> > ----- Original Message -----
> > From: "Richard Yee" <ry...@yahoo.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Thursday, December 19, 2002 6:11 PM
> > Subject: Re: beanutils.populate with formbeans and
> > vectors
> >
> >
> > > Michael,
> > > You need to put the methods that I sent in the
> > > FormBean class and not your Vector subclass. You
> > > really don't need to subclass the Vector.
> > >
> > >
> > > ex.
> > >
> > > public class MyForm extends ActionForm
> > > {
> > > private Vector myFoos = new Vector();
> > >
> > > /**
> > > * getter for indexed property in myFoos
> > > */
> > > public Object getFoo(int index) {
> > > if (index >= myFoos.size())
> > > return "";
> > > return myFoos.get(index);
> > > }
> > >
> > > /**
> > > * setter for indexed property in myFoos
> > > */
> > > public void setFoo(int index, Object value) {
> > > int size=myFoos.size();
> > > if (index >= size) {
> > > for(int i=size; i<=index; i++) {
> > > myFoos.add("");
> > > }
> > > }
> > > myFoos.set(index,value);
> > > }
> > >
> > >
> > > }
> > >
> > >
> > > -Richard
> > >
> > > > Does anybody have an idea, where this exception
> > is
> > > > from. I´m still working on it......
> >
> === message truncated ===
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: beanutils.populate with formbeans and vectors
Posted by Richard Yee <ry...@yahoo.com>.
Michael,
How are you accessing the indexed property in the JSP?
-Richard
--- Michael Olszynski <m....@proway.de> wrote:
> Hi Richard,
>
> thanks again for your quick reply. I thought I need
> to subclass Vector,
> because I don�t save plain Strings in my Vector, I
> save Beans in it. So
> therefore I thought I need to have a polymorhism to
> save myself the work to
> write always indexed setters and getters . But
> anyway, I put the code you
> wrote me in my bean, and I still get errors. I give
> you a small snippet of
> my code (I tried to remove everything unnecessary)
> and I also attach the
> errormessage after the samplecode. I�d really
> appreciate if you could look
> at it for a short moment. Thanks a lot
>
> Take care Michael
>
> ****************************************************
> public class TimeProofFormBean extends ActionForm {
>
> private Vector timeProofList = new Vector();
>
> public Vector getTimeProofList() {
> return this.timeProofList;
> }
>
> public void setTimeProofList( Vector v ) {
> this.timeProofList = v;
> }
>
>
> /**
> * getter for indexed property in myFoos
> */
> public Object getTimeProofList(int index) {
> if (index >= timeProofList.size())
> return new TimeProofTableBean();
> return timeProofList.get(index);
> }
>
> /**
> * setter for indexed property in myFoos
> */
> public void setTimeProofList(int index, Object
> value) {
> int size=timeProofList.size();
> if (index >= size) {
> for(int i=size; i<=index; i++) {
> timeProofList.add(new
> TimeProofTableBean());
> }
> }
> timeProofList.set(index,value);
> }
>
>
> }
>
**********************************************************
> jsp page:
> <logic:iterate id="timeProofList" indexId="listIdx"
> name="timeProofForm"
> property="timeProofList">
> <tr>
> <td> <html:text name="timeProofList"
> property="fromHour" size="2"
> maxlength="2" indexed="true"/>:
> <html:text name="timeProofList"
> property="fromMinute" size="2"
> maxlength="2" indexed="true"/> </td>
> </tr>
> </logic:iterate>
>
****************************************************************
>
> 18:35:35,684 ERROR [Engine]
> ApplicationDispatcher[/Zeiterfassung_Applikation] Se
> rvlet.service() for servlet jsp threw exception
> org.apache.jasper.JasperException: No getter method
> for property
> timeProofList o
> f bean timeProofForm
> at
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> .java:248)
> at
>
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> 89)
> at
>
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> atcher.java:684)
> at
>
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> ispatcher.java:575)
> at
>
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> patcher.java:498)
> at
>
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> .java:820)
> at
>
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> a:395)
> at
>
org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191)
> at
>
org.apache.jsp.template_jsp._jspx_meth_template_get_4(template_jsp.ja
> va:221)
> at
>
org.apache.jsp.template_jsp._jspx_meth_html_html_0(template_jsp.java:
> 118)
> at
>
org.apache.jsp.template_jsp._jspService(template_jsp.java:62)
> at
>
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
> at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> .java:204)
> at
>
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> 89)
> at
>
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
> at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
> atcher.java:684)
> at
>
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
> ispatcher.java:575)
> at
>
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
> patcher.java:498)
> at
>
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
> .java:820)
> at
>
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
> --
> Fehlerfreie Software wirkt weniger komplex und
> diskreditiert damit den
> Entwickler!
> ----- Original Message -----
> From: "Richard Yee" <ry...@yahoo.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, December 19, 2002 6:11 PM
> Subject: Re: beanutils.populate with formbeans and
> vectors
>
>
> > Michael,
> > You need to put the methods that I sent in the
> > FormBean class and not your Vector subclass. You
> > really don't need to subclass the Vector.
> >
> >
> > ex.
> >
> > public class MyForm extends ActionForm
> > {
> > private Vector myFoos = new Vector();
> >
> > /**
> > * getter for indexed property in myFoos
> > */
> > public Object getFoo(int index) {
> > if (index >= myFoos.size())
> > return "";
> > return myFoos.get(index);
> > }
> >
> > /**
> > * setter for indexed property in myFoos
> > */
> > public void setFoo(int index, Object value) {
> > int size=myFoos.size();
> > if (index >= size) {
> > for(int i=size; i<=index; i++) {
> > myFoos.add("");
> > }
> > }
> > myFoos.set(index,value);
> > }
> >
> >
> > }
> >
> >
> > -Richard
> >
> > > Does anybody have an idea, where this exception
> is
> > > from. I�m still working on it......
>
=== message truncated ===
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: beanutils.populate with formbeans and vectors
Posted by Michael Olszynski <m....@proway.de>.
Hi Richard,
thanks again for your quick reply. I thought I need to subclass Vector,
because I don´t save plain Strings in my Vector, I save Beans in it. So
therefore I thought I need to have a polymorhism to save myself the work to
write always indexed setters and getters . But anyway, I put the code you
wrote me in my bean, and I still get errors. I give you a small snippet of
my code (I tried to remove everything unnecessary) and I also attach the
errormessage after the samplecode. I´d really appreciate if you could look
at it for a short moment. Thanks a lot
Take care Michael
****************************************************
public class TimeProofFormBean extends ActionForm {
private Vector timeProofList = new Vector();
public Vector getTimeProofList() {
return this.timeProofList;
}
public void setTimeProofList( Vector v ) {
this.timeProofList = v;
}
/**
* getter for indexed property in myFoos
*/
public Object getTimeProofList(int index) {
if (index >= timeProofList.size())
return new TimeProofTableBean();
return timeProofList.get(index);
}
/**
* setter for indexed property in myFoos
*/
public void setTimeProofList(int index, Object value) {
int size=timeProofList.size();
if (index >= size) {
for(int i=size; i<=index; i++) {
timeProofList.add(new TimeProofTableBean());
}
}
timeProofList.set(index,value);
}
}
**********************************************************
jsp page:
<logic:iterate id="timeProofList" indexId="listIdx" name="timeProofForm"
property="timeProofList">
<tr>
<td> <html:text name="timeProofList" property="fromHour" size="2"
maxlength="2" indexed="true"/>:
<html:text name="timeProofList" property="fromMinute" size="2"
maxlength="2" indexed="true"/> </td>
</tr>
</logic:iterate>
****************************************************************
18:35:35,684 ERROR [Engine]
ApplicationDispatcher[/Zeiterfassung_Applikation] Se
rvlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: No getter method for property
timeProofList o
f bean timeProofForm
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:248)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
89)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:684)
at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
ispatcher.java:575)
at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
patcher.java:498)
at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
.java:820)
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
a:395)
at
org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191)
at
org.apache.jsp.template_jsp._jspx_meth_template_get_4(template_jsp.ja
va:221)
at
org.apache.jsp.template_jsp._jspx_meth_html_html_0(template_jsp.java:
118)
at org.apache.jsp.template_jsp._jspService(template_jsp.java:62)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:204)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
89)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:684)
at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
ispatcher.java:575)
at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
patcher.java:498)
at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
.java:820)
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.jav
--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
----- Original Message -----
From: "Richard Yee" <ry...@yahoo.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, December 19, 2002 6:11 PM
Subject: Re: beanutils.populate with formbeans and vectors
> Michael,
> You need to put the methods that I sent in the
> FormBean class and not your Vector subclass. You
> really don't need to subclass the Vector.
>
>
> ex.
>
> public class MyForm extends ActionForm
> {
> private Vector myFoos = new Vector();
>
> /**
> * getter for indexed property in myFoos
> */
> public Object getFoo(int index) {
> if (index >= myFoos.size())
> return "";
> return myFoos.get(index);
> }
>
> /**
> * setter for indexed property in myFoos
> */
> public void setFoo(int index, Object value) {
> int size=myFoos.size();
> if (index >= size) {
> for(int i=size; i<=index; i++) {
> myFoos.add("");
> }
> }
> myFoos.set(index,value);
> }
>
>
> }
>
>
> -Richard
>
> > Does anybody have an idea, where this exception is
> > from. I´m still working on it......
> >
> > Thaks a lot, Michael
> > --
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>