You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Puneet Lakhina <pu...@gmail.com> on 2006/11/02 19:53:40 UTC

DynaActionForm indexed properties

Hi,
This is the first time I am trying to use indexed properties with
DynaActionForm. Now the number of fields that I will have is not certain. So
does that mean I cant use DynaActionForm. And i don't have normal strings in
my list. I have a custom object.

so what i have currently is something like this

<form-bean name="dynaForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="number" type="mypackage.Number[]" />
</form-bean>

I cant specify any size because I don't know the size before hand. So this
has no problems loading the page, but on submit it throws an
ArrayIndexOutOfBoundsException.
-- 
Puneet

Re: DynaActionForm indexed properties

Posted by Ed Griebel <ed...@gmail.com>.
If you are using basic arrays you need to create an array for the item
before the JSP is displayed.

You might want to use a java.util.List instead, you don't need to
pre-allocate when using Dyna forms.

HTH,
-ed

On 11/2/06, Puneet Lakhina <pu...@gmail.com> wrote:
> Hi,
> This is the first time I am trying to use indexed properties with
> DynaActionForm. Now the number of fields that I will have is not certain. So
> does that mean I cant use DynaActionForm. And i don't have normal strings in
> my list. I have a custom object.
>
> so what i have currently is something like this
>
> <form-bean name="dynaForm" type="org.apache.struts.action.DynaActionForm">
> <form-property name="number" type="mypackage.Number[]" />
> </form-bean>
>
> I cant specify any size because I don't know the size before hand. So this
> has no problems loading the page, but on submit it throws an
> ArrayIndexOutOfBoundsException.
> --
> Puneet
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: DynaActionForm indexed properties

Posted by Niall Pemberton <ni...@gmail.com>.
On 11/3/06, Puneet Lakhina <pu...@gmail.com> wrote:
> On 11/3/06, Niall Pemberton <ni...@gmail.com> wrote:
> >
> > On 11/2/06, Puneet Lakhina <pu...@gmail.com> wrote:
> > > Hi,
> > > This is the first time I am trying to use indexed properties with
> > > DynaActionForm. Now the number of fields that I will have is not
> > certain. So
> > > does that mean I cant use DynaActionForm. And i don't have normal
> > strings in
> > > my list. I have a custom object.
> > >
> > > so what i have currently is something like this
> > >
> > > <form-bean name="dynaForm" type="org.apache.struts.action.DynaActionForm
> > ">
> > > <form-property name="number" type="mypackage.Number[]" />
> > > </form-bean>
> > >
> > > I cant specify any size because I don't know the size before hand. So
> > this
> > > has no problems loading the page, but on submit it throws an
> > > ArrayIndexOutOfBoundsException.
> >
> > LazyDynaBeans automatically grows Lists and arrays to the right size:
> >
> >
> > http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes
>
>
> Thanks seems like the exact thing I wanted. But I'm stuck on struts 1.1 at
> my workplace and based on this
> http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html LazyActionform
> has been added to struts 1.2.6
> Is it possible to plug this thing into 1.1?has anybody done that?
> Thanks

I haven't heard of anyone doing it, but you should be able to.
LazyDynaBean was added to Commons BeanUtils 1.7.0 and Struts 1.1
depends on a version prior to that. If you can upgrade to BeanUtils
1.7.0 then you have most of the functionality. You could use them as a
property in your ActionForm - or replicate the Struts
LazyValidatorForm (theres not too much to it), If you can't upgrade to
BeanUtils 1.7.0 then you could just grab the source code for the two
"lazy" classes you need (LazyDynaBean and LazyDynaClass) and they
should work OK with BeanUtils 1.6.1 - which is the version that Ships
with Struts 1.1

You can grab the source download from here for Commons BeanUtils:

http://jakarta.apache.org/site/downloads/downloads_commons-beanutils.cgi

Niall

> Niall
> >
> > > --
> > > Puneet

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: DynaActionForm indexed properties

Posted by Puneet Lakhina <pu...@gmail.com>.
On 11/3/06, Niall Pemberton <ni...@gmail.com> wrote:
>
> On 11/2/06, Puneet Lakhina <pu...@gmail.com> wrote:
> > Hi,
> > This is the first time I am trying to use indexed properties with
> > DynaActionForm. Now the number of fields that I will have is not
> certain. So
> > does that mean I cant use DynaActionForm. And i don't have normal
> strings in
> > my list. I have a custom object.
> >
> > so what i have currently is something like this
> >
> > <form-bean name="dynaForm" type="org.apache.struts.action.DynaActionForm
> ">
> > <form-property name="number" type="mypackage.Number[]" />
> > </form-bean>
> >
> > I cant specify any size because I don't know the size before hand. So
> this
> > has no problems loading the page, but on submit it throws an
> > ArrayIndexOutOfBoundsException.
>
> LazyDynaBeans automatically grows Lists and arrays to the right size:
>
>
> http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes


Thanks seems like the exact thing I wanted. But I'm stuck on struts 1.1 at
my workplace and based on this
http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html LazyActionform
has been added to struts 1.2.6
Is it possible to plug this thing into 1.1?has anybody done that?
Thanks

Niall
>
> > --
> > Puneet
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Puneet

Re: DynaActionForm indexed properties

Posted by Niall Pemberton <ni...@gmail.com>.
On 11/2/06, Puneet Lakhina <pu...@gmail.com> wrote:
> Hi,
> This is the first time I am trying to use indexed properties with
> DynaActionForm. Now the number of fields that I will have is not certain. So
> does that mean I cant use DynaActionForm. And i don't have normal strings in
> my list. I have a custom object.
>
> so what i have currently is something like this
>
> <form-bean name="dynaForm" type="org.apache.struts.action.DynaActionForm">
> <form-property name="number" type="mypackage.Number[]" />
> </form-bean>
>
> I cant specify any size because I don't know the size before hand. So this
> has no problems loading the page, but on submit it throws an
> ArrayIndexOutOfBoundsException.

LazyDynaBeans automatically grows Lists and arrays to the right size:

  http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes

Niall

> --
> Puneet

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org