You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Phase Web and Multimedia <ma...@phase.ws> on 2002/09/14 04:46:17 UTC
Nested Extension Buff ABSOLUTELY needed
If anyone has good functioning code that they are willing to give snippets
of in order to help me understand the nested extension i would love to hear
from them. I obviously am not doing something right. I have speicified my
getter/setters that receive and send an Object arrays wich uses an ArrayList
in the bean so that the bean will maintain array size flexibility and still
interact with the indexed form elements being sent to it. I keep getting the
following error and it appears to happen whenever the ActionForm is
attempting to be populated from the request. I am frustrated and in need.
The following is the error i am getting.
java.lang.ArrayIndexOutOfBoundsException
at java.lang.reflect.Array.get(Native Method)
at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.
java:507)
at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.
java:410)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
ava:749)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:78
0)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:978)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:779)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:246)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
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(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
46)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1027)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
)
at java.lang.Thread.run(Thread.java:536)
Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [SOLVED]RE: Nested Extension Buff ABSOLUTELY needed
Posted by Eddie Bush <ek...@swbell.net>.
Look for his most recent post entitled:
Nesting Extension/Lasy List Example - Now with extra whitening source
code!!!
There's a link in the message for you to download the WAR.
Regards,
Eddie
Cristian Cardenas wrote:
>Hello, Brandon
>I have the same problem than you about indexed properties.
>Could you send me some source code of how did you solve it?
>
>Thanks.
>Cristian.
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [SOLVED]RE: Nested Extension Buff ABSOLUTELY needed
Posted by Cristian Cardenas <cc...@lacmail.corp.fedex.com>.
Hello, Brandon
I have the same problem than you about indexed properties.
Could you send me some source code of how did you solve it?
Thanks.
Cristian.
----- Original Message -----
From: "Phase Web and Multimedia" <ma...@phase.ws>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>;
<st...@keyboardmonkey.com>
Sent: Sunday, September 15, 2002 3:51 PM
Subject: [SOLVED]RE: Nested Extension Buff ABSOLUTELY needed
> Incredible!
>
> After doing a little digging in the source code of commons beanutils and
> collections i began to see what is going on and how these properties were
> being populated. After discovering that the actual
ArrayOutOfBoundsException
> was being thrown when PropertyUtils.getIndexedProperty was trying to do a
> lookup on a property that doesn't exist. It didn't exist because the List
> had not yet been populated with the number of objects attempting to be
> retrieved(i.e. it was looking for Object[5] and the List was only
Object[0].
> So then the "LazyList" mentioned by Arron began to make since. I have it
all
> up and working. It's way cool and it gives me the flexibility i need.
>
> Arron. I have this sample code that may help others to put it all
together.
> If you would like i would be happy to tidy it up and give it to you to
> review and post if you deem it worthy. It's a simple example and should
help
> give anyone a real base that can be used in a production environment. Let
me
> know if you want it. I'll be more than happy to send it to you. It will
help
> me to feel like all my time fguring it out wasn't a waste. It is actually
> very easy. :-)
>
> Thanks,
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
> > -----Original Message-----
> > From: Phase Web and Multimedia [mailto:mail@phase.ws]
> > Sent: Sunday, September 15, 2002 1:50 AM
> > To: Struts Users Mailing List; struts-user@keyboardmonkey.com
> > Subject: RE: Nested Extension Buff ABSOLUTELY needed
> >
> >
> > Arron,
> >
> > To help me understand a bit...
> >
> > When I have an array of form elements that is sent via the request to
> > populate my beans it:
> > 1) does not use the setXXX method to access properties
> > 2) accesses the property directly
> > 3) invokes the objects contructor
> >
> > Are these correct?
> >
> > For example,
> > i have a parent class:
> > 1) has a class scope ArrayList that is called child - private ArrayList
> > child;
> > 2) the constructor intializes the child ArrayList - child = new
> > ArrayList();
> > 3) i have a setChild method (like following) in my Parent class
> > that sets an
> > ArrayList of Child objects using an Object[] then translating it to an
> > ArrayList
> >
> > public void setChild(Object[] nestChild) {
> > this.child = new Vector();
> > for(int pop=0; pop < child.length; pop++){
> > this.child.add(child[pop]);
> > }
> > }
> >
> > 4) when the request from the form is sent to populate the ActionForm i
get
> > an ArrayIndexOutOfBoundsException
> > 5) but when i hard code the initialization and population of my child
> > ArrayList in the constructor with enough Child Objects it works
> > ....constructor
> > child = new ArrayList();
> > child.add(new Child());
> > child.add(new Child());
> > ... additional adds to allow enough child object to map to
> > the array of
> > form elements sent in the request
> >
> > The problem here is the initialization/constructor hardcoding of enough
> > space in my ArrayList to be referenced by the incoming request
> > values array.
> >
> > I looked at the collections class and methods that you sent me. I
> > just don't
> > see how those will help me solve this.
> >
> > Can you expound a bit for me. Once i see it clearly i would like to
> > contribute a working example of it for others to use.
> >
> > I feel like i am so close
> >
> > P.S. i posted a sample of my code earlier with the message header
> > "RE: Help!
> > Please! RE: Nested Beans"
> >
> > Thanks,
> > Brandon Goodin
> > Phase Web and Multimedia
> > P (406) 862-2245
> > F (406) 862-0354
> > mail@phase.ws
> > http://www.phase.ws
> >
> >
> > > -----Original Message-----
> > > From: Arron Bates [mailto:struts-user@keyboardmonkey.com]
> > > Sent: Saturday, September 14, 2002 9:41 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: Nested Extension Buff ABSOLUTELY needed
> > >
> > >
> > > Wouldn't say I'm a "Buff" but anyways...
> > >
> > > As far as I can tell you want to keep the object model out of the
> > > session, but still get all the updates from the form when it
submits?...
> > >
> > > This is a general indexed item problem, not just a nested problem.
It's
> > > just that the nested tags make list stuff easier.
> > >
> > > Way around it?... it to have a list that grows as it needs to. I've
made
> > > such a beastie and it now sits in the Commons collections package. In
> > > the...
> > >
> > > org.apache.commons.collections.ListUtils
> > >
> > > ...class. Ask it to make you a new LazyList, or a LazyMap depending on
> > > the type of collection you have, and it'll do the dance.
> > >
> > > When you make a List to put your beans in, wrap it with this
collection
> > > wrapper with a class definition of your child bean, and it will grow
the
> > > list as it needs to when the form comes in. Eg: index comes in for
bean
> > > x, the list will grow up to index x, create a bean by the definition
you
> > > passed it, and then set the values that it needs to.
> > >
> > > The class has much JavaDoc. Hopefully it'll be enough to get you
> > > running. Actually, I just had a look. I originally had it in its own
> > > class. It's merged into the above ListUtils, but whoever did it didn't
> > > take through the JavaDoc. So... give it a bash, and get back to me if
> > > you're having major problems.
> > >
> > > Works a treat. To do it otherwise is a real hassle.
> > >
> > > Arron.
> > >
> > >
> > >
> > > On Sat, 2002-09-14 at 12:46, Phase Web and Multimedia wrote:
> > > > If anyone has good functioning code that they are willing to
> > > give snippets
> > > > of in order to help me understand the nested extension i would
> > > love to hear
> > > > from them. I obviously am not doing something right. I have
> > > speicified my
> > > > getter/setters that receive and send an Object arrays wich uses
> > > an ArrayList
> > > > in the bean so that the bean will maintain array size
> > > flexibility and still
> > > > interact with the indexed form elements being sent to it. I
> > > keep getting the
> > > > following error and it appears to happen whenever the ActionForm is
> > > > attempting to be populated from the request. I am frustrated
> > > and in need.
> > > > The following is the error i am getting.
> > > >
> > > > java.lang.ArrayIndexOutOfBoundsException
> > > > at java.lang.reflect.Array.get(Native Method)
> > > > at
> > > >
> > > org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Prop
> > > ertyUtils.
> > > > java:507)
> > > > at
> > > >
> > > org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Prop
> > > ertyUtils.
> > > > java:410)
> > > > at
> > > >
> > > org.apache.commons.beanutils.PropertyUtils.getNestedProperty(Prope
> > > rtyUtils.j
> > > > ava:749)
> > > > at
> > > >
> > > org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUti
> > > ls.java:78
> > > > 0)
> > > > at
> > > org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793)
> > > > at
> > > org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
> > > > at
> > > org.apache.struts.util.RequestUtils.populate(RequestUtils.java:978)
> > > > at
> > > >
> > > org.apache.struts.action.RequestProcessor.processPopulate(RequestP
> > > rocessor.j
> > > > ava:779)
> > > > at
> > > >
> > > org.apache.struts.action.RequestProcessor.process(RequestProcessor
> > > .java:246)
> > > > at
> > > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292
)
> > > > 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(A
> > > pplication
> > > > FilterChain.java:247)
> > > > at
> > > >
> > > org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicati
> > > onFilterCh
> > > > ain.java:193)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapp
> > > erValve.ja
> > > > va:243)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 66)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > > java:472)
> > > > at
> > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardContextValve.invoke(StandardConte
> > > xtValve.ja
> > > > va:190)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 66)
> > > > at
> > > >
> > > org.apache.catalina.valves.CertificatesValve.invoke(CertificatesVa
> > > lve.java:2
> > > > 46)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 64)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > > java:472)
> > > > at
> > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > > at
> > > >
> > >
> >
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValv
> > > e.java:180
> > > > )
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 66)
> > > > at
> > > >
> > > org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispat
> > > cherValve.
> > > > java:170)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 64)
> > > > at
> > > >
> > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValv
> > > e.java:170
> > > > )
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 64)
> > > > at
> > > >
> > >
> >
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 64)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > > java:472)
> > > > at
> > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngine
> > > Valve.java
> > > > :174)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > > ine.java:5
> > > > 66)
> > > > at
> > > >
> > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > > java:472)
> > > > at
> > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > > at
> > > >
> > > org.apache.catalina.connector.http.HttpProcessor.process(HttpProce
> > > ssor.java:
> > > > 1027)
> > > > at
> > > >
> > > org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor
> > > .java:1125
> > > > )
> > > > at java.lang.Thread.run(Thread.java:536)
> > > >
> > > > Brandon Goodin
> > > > Phase Web and Multimedia
> > > > P (406) 862-2245
> > > > F (406) 862-0354
> > > > mail@phase.ws
> > > > http://www.phase.ws
> > > >
> > > >
> > > >
> > > > --
> > > > 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>
> >
> >
>
>
> --
> 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>
[SOLVED]RE: Nested Extension Buff ABSOLUTELY needed
Posted by Phase Web and Multimedia <ma...@phase.ws>.
Incredible!
After doing a little digging in the source code of commons beanutils and
collections i began to see what is going on and how these properties were
being populated. After discovering that the actual ArrayOutOfBoundsException
was being thrown when PropertyUtils.getIndexedProperty was trying to do a
lookup on a property that doesn't exist. It didn't exist because the List
had not yet been populated with the number of objects attempting to be
retrieved(i.e. it was looking for Object[5] and the List was only Object[0].
So then the "LazyList" mentioned by Arron began to make since. I have it all
up and working. It's way cool and it gives me the flexibility i need.
Arron. I have this sample code that may help others to put it all together.
If you would like i would be happy to tidy it up and give it to you to
review and post if you deem it worthy. It's a simple example and should help
give anyone a real base that can be used in a production environment. Let me
know if you want it. I'll be more than happy to send it to you. It will help
me to feel like all my time fguring it out wasn't a waste. It is actually
very easy. :-)
Thanks,
Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws
> -----Original Message-----
> From: Phase Web and Multimedia [mailto:mail@phase.ws]
> Sent: Sunday, September 15, 2002 1:50 AM
> To: Struts Users Mailing List; struts-user@keyboardmonkey.com
> Subject: RE: Nested Extension Buff ABSOLUTELY needed
>
>
> Arron,
>
> To help me understand a bit...
>
> When I have an array of form elements that is sent via the request to
> populate my beans it:
> 1) does not use the setXXX method to access properties
> 2) accesses the property directly
> 3) invokes the objects contructor
>
> Are these correct?
>
> For example,
> i have a parent class:
> 1) has a class scope ArrayList that is called child - private ArrayList
> child;
> 2) the constructor intializes the child ArrayList - child = new
> ArrayList();
> 3) i have a setChild method (like following) in my Parent class
> that sets an
> ArrayList of Child objects using an Object[] then translating it to an
> ArrayList
>
> public void setChild(Object[] nestChild) {
> this.child = new Vector();
> for(int pop=0; pop < child.length; pop++){
> this.child.add(child[pop]);
> }
> }
>
> 4) when the request from the form is sent to populate the ActionForm i get
> an ArrayIndexOutOfBoundsException
> 5) but when i hard code the initialization and population of my child
> ArrayList in the constructor with enough Child Objects it works
> ....constructor
> child = new ArrayList();
> child.add(new Child());
> child.add(new Child());
> ... additional adds to allow enough child object to map to
> the array of
> form elements sent in the request
>
> The problem here is the initialization/constructor hardcoding of enough
> space in my ArrayList to be referenced by the incoming request
> values array.
>
> I looked at the collections class and methods that you sent me. I
> just don't
> see how those will help me solve this.
>
> Can you expound a bit for me. Once i see it clearly i would like to
> contribute a working example of it for others to use.
>
> I feel like i am so close
>
> P.S. i posted a sample of my code earlier with the message header
> "RE: Help!
> Please! RE: Nested Beans"
>
> Thanks,
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
> > -----Original Message-----
> > From: Arron Bates [mailto:struts-user@keyboardmonkey.com]
> > Sent: Saturday, September 14, 2002 9:41 PM
> > To: Struts Users Mailing List
> > Subject: Re: Nested Extension Buff ABSOLUTELY needed
> >
> >
> > Wouldn't say I'm a "Buff" but anyways...
> >
> > As far as I can tell you want to keep the object model out of the
> > session, but still get all the updates from the form when it submits?...
> >
> > This is a general indexed item problem, not just a nested problem. It's
> > just that the nested tags make list stuff easier.
> >
> > Way around it?... it to have a list that grows as it needs to. I've made
> > such a beastie and it now sits in the Commons collections package. In
> > the...
> >
> > org.apache.commons.collections.ListUtils
> >
> > ...class. Ask it to make you a new LazyList, or a LazyMap depending on
> > the type of collection you have, and it'll do the dance.
> >
> > When you make a List to put your beans in, wrap it with this collection
> > wrapper with a class definition of your child bean, and it will grow the
> > list as it needs to when the form comes in. Eg: index comes in for bean
> > x, the list will grow up to index x, create a bean by the definition you
> > passed it, and then set the values that it needs to.
> >
> > The class has much JavaDoc. Hopefully it'll be enough to get you
> > running. Actually, I just had a look. I originally had it in its own
> > class. It's merged into the above ListUtils, but whoever did it didn't
> > take through the JavaDoc. So... give it a bash, and get back to me if
> > you're having major problems.
> >
> > Works a treat. To do it otherwise is a real hassle.
> >
> > Arron.
> >
> >
> >
> > On Sat, 2002-09-14 at 12:46, Phase Web and Multimedia wrote:
> > > If anyone has good functioning code that they are willing to
> > give snippets
> > > of in order to help me understand the nested extension i would
> > love to hear
> > > from them. I obviously am not doing something right. I have
> > speicified my
> > > getter/setters that receive and send an Object arrays wich uses
> > an ArrayList
> > > in the bean so that the bean will maintain array size
> > flexibility and still
> > > interact with the indexed form elements being sent to it. I
> > keep getting the
> > > following error and it appears to happen whenever the ActionForm is
> > > attempting to be populated from the request. I am frustrated
> > and in need.
> > > The following is the error i am getting.
> > >
> > > java.lang.ArrayIndexOutOfBoundsException
> > > at java.lang.reflect.Array.get(Native Method)
> > > at
> > >
> > org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Prop
> > ertyUtils.
> > > java:507)
> > > at
> > >
> > org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Prop
> > ertyUtils.
> > > java:410)
> > > at
> > >
> > org.apache.commons.beanutils.PropertyUtils.getNestedProperty(Prope
> > rtyUtils.j
> > > ava:749)
> > > at
> > >
> > org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUti
> > ls.java:78
> > > 0)
> > > at
> > org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793)
> > > at
> > org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
> > > at
> > org.apache.struts.util.RequestUtils.populate(RequestUtils.java:978)
> > > at
> > >
> > org.apache.struts.action.RequestProcessor.processPopulate(RequestP
> > rocessor.j
> > > ava:779)
> > > at
> > >
> > org.apache.struts.action.RequestProcessor.process(RequestProcessor
> > .java:246)
> > > at
> > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
> > > 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(A
> > pplication
> > > FilterChain.java:247)
> > > at
> > >
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicati
> > onFilterCh
> > > ain.java:193)
> > > at
> > >
> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapp
> > erValve.ja
> > > va:243)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 66)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > java:472)
> > > at
> > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > at
> > >
> > org.apache.catalina.core.StandardContextValve.invoke(StandardConte
> > xtValve.ja
> > > va:190)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 66)
> > > at
> > >
> > org.apache.catalina.valves.CertificatesValve.invoke(CertificatesVa
> > lve.java:2
> > > 46)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 64)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > java:472)
> > > at
> > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > at
> > >
> >
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
> > > at
> > >
> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValv
> > e.java:180
> > > )
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 66)
> > > at
> > >
> > org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispat
> > cherValve.
> > > java:170)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 64)
> > > at
> > >
> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValv
> > e.java:170
> > > )
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 64)
> > > at
> > >
> >
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 64)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > java:472)
> > > at
> > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > at
> > >
> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngine
> > Valve.java
> > > :174)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> > ine.java:5
> > > 66)
> > > at
> > >
> > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> > java:472)
> > > at
> > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > > at
> > >
> > org.apache.catalina.connector.http.HttpProcessor.process(HttpProce
> > ssor.java:
> > > 1027)
> > > at
> > >
> > org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor
> > .java:1125
> > > )
> > > at java.lang.Thread.run(Thread.java:536)
> > >
> > > Brandon Goodin
> > > Phase Web and Multimedia
> > > P (406) 862-2245
> > > F (406) 862-0354
> > > mail@phase.ws
> > > http://www.phase.ws
> > >
> > >
> > >
> > > --
> > > 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>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Nested Extension Buff ABSOLUTELY needed
Posted by Phase Web and Multimedia <ma...@phase.ws>.
Arron,
To help me understand a bit...
When I have an array of form elements that is sent via the request to
populate my beans it:
1) does not use the setXXX method to access properties
2) accesses the property directly
3) invokes the objects contructor
Are these correct?
For example,
i have a parent class:
1) has a class scope ArrayList that is called child - private ArrayList
child;
2) the constructor intializes the child ArrayList - child = new ArrayList();
3) i have a setChild method (like following) in my Parent class that sets an
ArrayList of Child objects using an Object[] then translating it to an
ArrayList
public void setChild(Object[] nestChild) {
this.child = new Vector();
for(int pop=0; pop < child.length; pop++){
this.child.add(child[pop]);
}
}
4) when the request from the form is sent to populate the ActionForm i get
an ArrayIndexOutOfBoundsException
5) but when i hard code the initialization and population of my child
ArrayList in the constructor with enough Child Objects it works
....constructor
child = new ArrayList();
child.add(new Child());
child.add(new Child());
... additional adds to allow enough child object to map to the array of
form elements sent in the request
The problem here is the initialization/constructor hardcoding of enough
space in my ArrayList to be referenced by the incoming request values array.
I looked at the collections class and methods that you sent me. I just don't
see how those will help me solve this.
Can you expound a bit for me. Once i see it clearly i would like to
contribute a working example of it for others to use.
I feel like i am so close
P.S. i posted a sample of my code earlier with the message header "RE: Help!
Please! RE: Nested Beans"
Thanks,
Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws
> -----Original Message-----
> From: Arron Bates [mailto:struts-user@keyboardmonkey.com]
> Sent: Saturday, September 14, 2002 9:41 PM
> To: Struts Users Mailing List
> Subject: Re: Nested Extension Buff ABSOLUTELY needed
>
>
> Wouldn't say I'm a "Buff" but anyways...
>
> As far as I can tell you want to keep the object model out of the
> session, but still get all the updates from the form when it submits?...
>
> This is a general indexed item problem, not just a nested problem. It's
> just that the nested tags make list stuff easier.
>
> Way around it?... it to have a list that grows as it needs to. I've made
> such a beastie and it now sits in the Commons collections package. In
> the...
>
> org.apache.commons.collections.ListUtils
>
> ...class. Ask it to make you a new LazyList, or a LazyMap depending on
> the type of collection you have, and it'll do the dance.
>
> When you make a List to put your beans in, wrap it with this collection
> wrapper with a class definition of your child bean, and it will grow the
> list as it needs to when the form comes in. Eg: index comes in for bean
> x, the list will grow up to index x, create a bean by the definition you
> passed it, and then set the values that it needs to.
>
> The class has much JavaDoc. Hopefully it'll be enough to get you
> running. Actually, I just had a look. I originally had it in its own
> class. It's merged into the above ListUtils, but whoever did it didn't
> take through the JavaDoc. So... give it a bash, and get back to me if
> you're having major problems.
>
> Works a treat. To do it otherwise is a real hassle.
>
> Arron.
>
>
>
> On Sat, 2002-09-14 at 12:46, Phase Web and Multimedia wrote:
> > If anyone has good functioning code that they are willing to
> give snippets
> > of in order to help me understand the nested extension i would
> love to hear
> > from them. I obviously am not doing something right. I have
> speicified my
> > getter/setters that receive and send an Object arrays wich uses
> an ArrayList
> > in the bean so that the bean will maintain array size
> flexibility and still
> > interact with the indexed form elements being sent to it. I
> keep getting the
> > following error and it appears to happen whenever the ActionForm is
> > attempting to be populated from the request. I am frustrated
> and in need.
> > The following is the error i am getting.
> >
> > java.lang.ArrayIndexOutOfBoundsException
> > at java.lang.reflect.Array.get(Native Method)
> > at
> >
> org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Prop
> ertyUtils.
> > java:507)
> > at
> >
> org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Prop
> ertyUtils.
> > java:410)
> > at
> >
> org.apache.commons.beanutils.PropertyUtils.getNestedProperty(Prope
> rtyUtils.j
> > ava:749)
> > at
> >
> org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUti
> ls.java:78
> > 0)
> > at
> org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793)
> > at
> org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
> > at
> org.apache.struts.util.RequestUtils.populate(RequestUtils.java:978)
> > at
> >
> org.apache.struts.action.RequestProcessor.processPopulate(RequestP
> rocessor.j
> > ava:779)
> > at
> >
> org.apache.struts.action.RequestProcessor.process(RequestProcessor
> .java:246)
> > at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
> > 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(A
> pplication
> > FilterChain.java:247)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicati
> onFilterCh
> > ain.java:193)
> > at
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapp
> erValve.ja
> > va:243)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 66)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:472)
> > at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
> org.apache.catalina.core.StandardContextValve.invoke(StandardConte
> xtValve.ja
> > va:190)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 66)
> > at
> >
> org.apache.catalina.valves.CertificatesValve.invoke(CertificatesVa
> lve.java:2
> > 46)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 64)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:472)
> > at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
> > at
> >
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValv
> e.java:180
> > )
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 66)
> > at
> >
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispat
> cherValve.
> > java:170)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 64)
> > at
> >
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValv
> e.java:170
> > )
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 64)
> > at
> >
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 64)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:472)
> > at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngine
> Valve.java
> > :174)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipel
> ine.java:5
> > 66)
> > at
> >
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:472)
> > at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > at
> >
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProce
> ssor.java:
> > 1027)
> > at
> >
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor
> .java:1125
> > )
> > at java.lang.Thread.run(Thread.java:536)
> >
> > Brandon Goodin
> > Phase Web and Multimedia
> > P (406) 862-2245
> > F (406) 862-0354
> > mail@phase.ws
> > http://www.phase.ws
> >
> >
> >
> > --
> > 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: Nested Extension Buff ABSOLUTELY needed
Posted by Arron Bates <st...@keyboardmonkey.com>.
Wouldn't say I'm a "Buff" but anyways...
As far as I can tell you want to keep the object model out of the
session, but still get all the updates from the form when it submits?...
This is a general indexed item problem, not just a nested problem. It's
just that the nested tags make list stuff easier.
Way around it?... it to have a list that grows as it needs to. I've made
such a beastie and it now sits in the Commons collections package. In
the...
org.apache.commons.collections.ListUtils
...class. Ask it to make you a new LazyList, or a LazyMap depending on
the type of collection you have, and it'll do the dance.
When you make a List to put your beans in, wrap it with this collection
wrapper with a class definition of your child bean, and it will grow the
list as it needs to when the form comes in. Eg: index comes in for bean
x, the list will grow up to index x, create a bean by the definition you
passed it, and then set the values that it needs to.
The class has much JavaDoc. Hopefully it'll be enough to get you
running. Actually, I just had a look. I originally had it in its own
class. It's merged into the above ListUtils, but whoever did it didn't
take through the JavaDoc. So... give it a bash, and get back to me if
you're having major problems.
Works a treat. To do it otherwise is a real hassle.
Arron.
On Sat, 2002-09-14 at 12:46, Phase Web and Multimedia wrote:
> If anyone has good functioning code that they are willing to give snippets
> of in order to help me understand the nested extension i would love to hear
> from them. I obviously am not doing something right. I have speicified my
> getter/setters that receive and send an Object arrays wich uses an ArrayList
> in the bean so that the bean will maintain array size flexibility and still
> interact with the indexed form elements being sent to it. I keep getting the
> following error and it appears to happen whenever the ActionForm is
> attempting to be populated from the request. I am frustrated and in need.
> The following is the error i am getting.
>
> java.lang.ArrayIndexOutOfBoundsException
> at java.lang.reflect.Array.get(Native Method)
> at
> org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.
> java:507)
> at
> org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.
> java:410)
> at
> org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
> ava:749)
> at
> org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:78
> 0)
> at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793)
> at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
> at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:978)
> at
> org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
> ava:779)
> at
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:246)
> at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
> 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(Application
> FilterChain.java:247)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:193)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:243)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:190)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
> 46)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
> )
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
> java:170)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
> )
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :174)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> 1027)
> at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
> )
> at java.lang.Thread.run(Thread.java:536)
>
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
>
> --
> 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>