struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric ...@ir.iit.edu>
Subject Re: iterative (list-type) form parameters
Date Tue, 07 Nov 2000 02:52:27 GMT
Ya, I kind of phrased it poorly.  I had been doing this with a bunch
of servlets that called request.getParameter in a loop.  In that
situation, I had a bunch of form parameters like this:

Zoo1Animal1
Zoo1Animal2
Zoo1Animal3
Zoo2Animal1
Zoo2Animal2

But I want to switch over to JSP (and struts) to clean things up a bit.

I was looking for the best way to get these into a bean (since a
simple setProperty * doesn't do this kind of stuff) and I didn't want
to define fields in the bean like "Zoo1Animal1" because that seems
really dirty to me.  I don't think the whole "iterate" thing is
relevant...isn't that just for output?

The way that I believe I have found to be best (I haven't tested it
yet and it's fairly undocumented) is to create a bean with an array
of different beans property such as "AnimalForm[] Zoos" and then in the
other bean (AnimalForm) have an array of strings property such as
"String[] Animals".  Then, I set up my jsp page to have form inputs
such as:

<form:text property="zoos[1].animal[1]">

Does this sound reasonable?  Will it work?

thanks,
eric.

On Mon, Nov 06, 2000 at 07:33:33PM -0500, Gigen Thomas wrote:
> Hi There,
> 
> I am not really sure that  I understood ur question. Anyway....
> Well if its a bunch of values that you want to store and want to iterate
> through these values , you can have a Collection within ur Bean and then
> have get and set methods to access this Collection.
> 
> Regards,
> Gigen
> 
> 
> ----- Original Message -----
> From: Eric <ej@duvel.ir.iit.edu>
> To: <struts-user@jakarta.apache.org>
> Sent: Monday, November 06, 2000 3:06 AM
> Subject: iterative (list-type) form parameters
> 
> 
> > I haven't been able to find a good solution for this
> > anywhere...someone must do something decently elegant...
> >
> > Many of the forms that I have have parameters that repeat iteratively
> > (lists of things) like "Param1, Param2, ..."
> >
> > What is the best way to get these into a bean?  I hate to define a
> > bunch of properties in the bean for a fixed number of them...  I know
> > I could use the array type of property in the bean, but is there a way
> > to get the parameters in there easily?  What about parameters that are
> > multiply iterative like "Param1Sub1, Param1Sub2, Param2Sub1,
> > Param2Sub2, ..."?
> >
> > Any ideas?
> >
> 

-- 
 _____  _ 
| ____|(_)     http://www.iit.edu/~jenseri
|  _|  | |     Page me via ICQ at
| |___ | |     http://wwp.mirabilis.com/19022931
|______/ |     or by mailing 19022931@pager.mirabilis.com
     |__/

Mime
View raw message