wood burning stoves 2.0
The moose likes Struts and the fly likes Struts : Dynamic HTML form parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts : Dynamic HTML form parameters" Watch "Struts : Dynamic HTML form parameters" New topic

Struts : Dynamic HTML form parameters

Rohit Poddar
Ranch Hand

Joined: Aug 18, 2001
Posts: 36
I have a requirement where the HTML form input paramater names are dynamically generated and hence I cannot have them as property in ActionForm bean. How can I handle this in Struts framework? The input field I am trying to use will of type select.

Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
Moving this to the frameworks forum...
Vishal Pai

Joined: Mar 02, 2002
Posts: 16
Do map-backed forms in Struts 1.1 solve your problem?? They are forms which have have maps that carry the properties. Hence the number of request parameters can vary.

Regards,<br />Vishal
Ruud Steeghs
Ranch Hand

Joined: Jul 09, 2001
Posts: 56
DynaForms are configured in struts-config and can therefore only contain specified (number of) parameters.
What you can do, is write your own ActionForm containing a single map and populate this map yourself by writing a utility method for this.
Unfortunately, you will not be able to use Struts up to its max, but that's a small price to pay for still being able to use dynamic properties.
Michal Bienek

Joined: Jun 17, 2002
Posts: 29
After reading Ruud's response, I was just curious as to how one would be able to populate a map of attribute/value pairs when the methods on an ActionForm are meant to be used by Struts using relfection. You would still somehow need methods that are setters and getters for particular attribute names, no?
I agree. Here's the link: http://aspose.com/file-tools
subject: Struts : Dynamic HTML form parameters
It's not a secret anymore!