This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Dynamic Struts? 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 "Dynamic Struts?" Watch "Dynamic Struts?" New topic

Dynamic Struts?

Bart Allen

Joined: Dec 19, 2003
Posts: 21
I need to be able to dynamically generate form inputs (0-*) from DB. These input types can be any of the standard HTML Input types - which then need to be dynamically parsed and validated (with validation rules coming from DB). Is there an apparatus in Struts which I have not found as of yet that can perform all of these requirements dynamically?

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
I suppose you'll have to resort to using the DynaActionForm instead of a regular ActionForm and implement your validation in Java instead of XML.
Do wait for a second opinion, though, since I'm far from a Struts guru...

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
I'm not really sure what you're asking for. Are you asking for the html form and associated ActionForm to be dynamically generated? are you asking for the contents of an ActionForm to be dynamically generated? Or are you asking for something else? When you say "form inputs" do you mean <input> tags (or the associated <html:input> tags)?

Maybe you can give us an example of exactly what it is you would like generated?
Bart Allen

Joined: Dec 19, 2003
Posts: 21
Today I have a Custom Tag on a JSP that dynamically created from 0 to n html inputs: <input> or <select> or <textarea> that I create from an ArrayList of HTMLInput objects that are loaded from a database. Upon post, I pull all of the parameters from the request object and, using the ID's of the Objects from the same ArrayList of HTMLInput objects, reassign what it's current value is based upon any modifications made. This is also where I perform any type of validation and a possible forward to the original entry form if there were errors.
I am currently in the process of trying to migrate my application to Struts, and have been able to figure out how to replace the static forms and their input, but have not figured out how to handle the dynamic aspects of my above defined issue ->
I agree. Here's the link:
subject: Dynamic Struts?
It's not a secret anymore!