• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Struts : Dynamic HTML form parameters

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Thanks,
Rohit
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have been using Struts for a little of a year and I ran into this same problem some time ago. Truthfully, I never solved it. I couldn't find a way to make Struts do this, so for the one page that uses it, I just "punted" and wrote a servlet to do it.
The closest thing that I found is the DynaActionForm, which just allows you to specify all of the fields in the struts-config.xml file and not have to write your own validation bean ... but you have to know your fields. In your case, you don't know then ahead of them or they may be different each time.
Basically what I did was pass the name, type, and default values as hidden variables to my validation servlet and let it handle the rest. Struts is not well suited to some tasks.
I'll keep reading this forum though to see if someone else knows how to do it. I'm willing to change, but for now, what I have works.
Paul
 
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rohit Poddar:
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.
Thanks,
Rohit


Though newbiw to Struts and just two days back I understand power of struts [using struts tag in jsp. Wow its really seperate view from logic, now we need one good editor which can color differently struts tags.]
If you know max number of select then you can have member variables in Form beanm though most of them will be null.
Else you can give same name to all select and then can have one array as member var of FormBean.
 
Rohit Poddar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I like the idea of same name and array.
 
Can't .... do .... plaid .... So I did this tiny ad instead:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic