• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using struts and complex forms

 
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts forms only allow very static forms, since each form bean has to be predefined.
How do I make use of struts ActionForm if I need to implement forms with dynamic number of fields?
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the framework forum.
 
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
You'll want to read up on DynaActionForms and DynaValidatorActionForms in Struts 1.1 documentation. These classes extend the ActionForm class and allow you to define forms in the struts-config.xml file instead of as a hard-coded class. You might also want to read up on the other subclasses of DynaAction form to see if there are any that behave as you need.
Darryl
 
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depending on the nature of your form, you can also use array properties in your form bean. i.e. if you will have multiple rows of the same content, this would be an easy solution. If this is your problem, there should be plenty of docs available. Otherwise, you can use the aforementioned dynamic forms. Or, you can use what is still a better method IMHO and simply make multiple forms. Of course, it all depends on your needs.
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my ActionForm, I've a set of basic fields that are static, eg. username, password and such.
Other than that, we are allowed to attach new fields dynamically as setup by some config files.
I'll look into DynaAction form to see whether it'll solve the problem. I doubt it because dyna action form requires me to code the XML before hand.
For now, I'm parsing the parameters manually from the request inside Action class.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chu,
I'm interested in what you find. I've got a similar problem. I am planning on parsing XML, manually writing JSP for the form and the DynaActionForm in the <form-bean> struts-config.xml section. If anybody has a better idea I'm all ears.
Thanks and Regards,
David
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic