On Wed, 2 Apr 2003, Luiz-Otavio Zorzella wrote:

> Date: Wed, 02 Apr 2003 17:12:01 -0800
> From: Luiz-Otavio Zorzella <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: How to have a form where the field names are truly dynamic?
>
> Is it possible for struts to handle form beans (using DynaForms or
> anything else) to pass values to an Action Form from a form where the
> field names themselves are dynamic?
>
> For example, say I want to create a generic site for creating simple
> surveys, where someone would come and say: ask for "Name", "Address" and
> "Sex". These would be stored in the DB, and when someone came to answert
> the survey, a form would be created, based on these data stored in the
> DB, where the user would see textfields for each of them.
>
> Then, in the Action Form, I would do:
>
> String[] fieldNames = getDBNamesForSurvey (surveyId);
>
> for (int i=0; i<fieldNames.length (); i++)
>    doSomethingWith (form.get (fieldNames[i]));
>
> Thanks,
>

On a servlet 2.3 container, I would dispense with a form bean in this
scenario, and just call request.getParameterMap() in my Action.  On a
servlet 2.2 container I'd still dispense with the form bean, and use
request.getParameterNames() to build my own parameter Map, or just get
them individually.

> Zorzella

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to