Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts : Dynamic HTML form parameters

 
Rohit Poddar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the frameworks forum...
Simon
 
Vishal Pai
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ruud Steeghs
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ruud.
 
Michal Bienek
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic