You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ted Husted <hu...@apache.org> on 2003/03/18 19:42:21 UTC

Re: 'dynamic' form elements in a ActionForm

Struts 1.1 supports map-backed forms, but that doesn't resolve the input 
form issue.

I guess the key would be some type of tag that took a map and then 
generated a column of input fields. (Wouldn't work for everyone, since a 
lot of forms must be designed just so.) For extra credit, the entry 
names could (optionally) be resource keys that were used to find the 
label text.

Text fields would be easy. Others would need some type of JavaBean with 
properties to tell the tag what to output. A bit of work, but obviously 
doable.

I imagine it's possible to use the validator in a non-declarative way, 
but I don't know anyone whose doing that. If you can do a db query to 
get the information about the form, I imagine you could also do a query 
to get the information about validations for the form. It would probably 
be easier to write your own engine than adopt the validator. (It's not 
really that complicated to do.)

People often ask about this sort of thing, but most of us just can't get 
our head around the use case. It's hard to understand what you do with 
the dynamic data when it comes back. Most application don't allow you to 
input or update an arbitrary (e.g. dynamic) set of fields.

-T.

> Hi Ted,
> 
> I was looking at the struts mailing list archives for information on 
> generating dynamic forms/pages and came across a response you 
> posted(http://nagoya.apache.org/eyebrowse/ReadMsg?listName=struts-user@jakarta.apache.org&msgNo=30062). 
> I'm very interested in this since I'm working on a project that requires 
> me to create an input form that's composed of fields defined dynamically 
> from a database. In this regard, would you mind my asking some questions:
> 
> In http://jguru.com/forums/view.jsp?EID=567079, you mentioned that the 
> solution doesn't address dynamically writing tags or dynamic 
> validation.  Do you have any recommendations in this regard?  For ex. if 
> user selects form A, I do a db query to determine what fields are in 
> form A (i.e field name; data type-numeric, date, varchar; widget 
> type-checkbox, text, textarea, etc; and if a selection type widget, what 
> the valid choices are). Since your response was posted last Dec 2001, I 
> was wondering if you know of any new features or if you can point me to 
> any resources that would help me render the proper type of widget and 
> validate based on data type.  Is there any way to take advantage of the 
> validator framework in a non-declarative way?
> 
> On the Jakarta Struts extensions site, there was a link to 
> http://husted.com/struts/resources/DynamicProperties.htm.  This code was 
> based on Struts 1.0.  Do you know if v1.1 makes creation of the classes 
> mentioned in this URL unnessary? I was just curious since in your 
> response to the 'dynamic' form question, you mentioned that: "It's 
> difficult to do this in the 1.0.x release, but simple as pie in the
> 1.1 beta and nightly build."  What feature in 1.1 made it much simpler 
> to do than in 1.0?
> 
> I'm sorry to bother you with these questions. I'm quite new to Struts. 
> If you can spare the time to answer any of the above or offer any 
> suggestions, I'd really appreciate it.
> 
> Thanks a lot,
> 




-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org