You can dynamically generate the property name and thus the HTML object
names but then you need a set/get on the Form Bean from every possible
generated name.
JS
-----Original Message-----
From: Web Programmer [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 27, 2001 11:15 AM
To: [EMAIL PROTECTED]
Subject: RE: Obtaining multiple values from dynamically generate
textboxes
I think the problem with strut is that, when it
iterates it puts the same name for all the form
elements which it picks up from what you have set as
property in the <html:text> tag.
--- "Walker, John H." <[EMAIL PROTECTED]> wrote:
> Thanks for that,
> It would be nice if struts handled
> this scenario
> automatically - you could specify a prefix/suffix
> for a property and all the
> struts tags on a JSP that use the prefix/suffix in
> their property name will
> be concatenated into an array and one call will be
> made to a set/get method
> based on the prefix/suffix only. e.g.
>
> <html:select property="arrayTest1" . .. />
> <html:select property="arrayTest2 . . . />
>
>
> Form Bean
> getArrayTest(String[]); // the prefix is ArrayTest
> and the rest is
> stripped off
> setArrayTest(String[]);
>
> I noticed the struts source does have a concept of a
> prefix/suffix for a
> Http parameter but I am not sure what they are doing
> with it?
>
> The solution of looping thru the Http parameter list
> will work but I would
> like to keep my data collection in the form bean and
> not have to move it to
> the action bean.
>
> The get/set methods do not pass in the request
> object so I would have to
> save the request in a member variable to access it
> in the setMethod() which
> is not pretty.
>
> We have a solution that uses javascript to loop thru
> the multiple HTML text,
> select objects and copies the values to a hidden
> field as a delimited
> string. When the page is submitted the
> setHiddenField() is called passing in
> all the values as a concatenated string.
>
>
> JW
>
> -----Original Message-----
> From: Web Programmer
> [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 27, 2001 10:30 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Obtaining multilpe values from
> dynamically generate
> textboxes
>
>
> See Scott Walker's response to my question earlier
> today which worked. If you can't get it, post
> again.
>
>
> --- "Gogineni, Pratima" <[EMAIL PROTECTED]>
> wrote:
> > Hi - I am doing something similar. Dont know if
> its
> > the best way to do it.
> >
> > My form bean has an indexed property over a vector
> > of values (so that its
> > size can change dynamically ..)
> > The form bean also has a size property which tells
> > me how many values exist
> > in the indexed property.
> >
> > in the JSP page
> > I loop based on the size property and have
> > <html:text> elements that display
> > the indexed property in a text field.
> >
> > Pratima
> >
> > -----Original Message-----
> > From: Walker, John H.
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, April 27, 2001 9:56 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: Obtaining multilpe values from
> dynamically
> > generate textboxes
> >
> >
> > We have the senereo where we are dynamically
> > generating a number of
> > textfields. The number of textfields are not a
> known
> > entity so we cannot
> > have multiple setTextField1(), setTextField2()..
> > . methods on the Action Form. How does struts
> handle
> > this case where you
> > basically want all the values of the textFields
> > concatenated and passed into
> > one Action Form method as an Array.
> >
> > Any ideas.
> > Thanks
> > John Walker
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great
> prices
> http://auctions.yahoo.com/
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/