You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Natalie D Rassmann <na...@lmco.com> on 2003/07/10 20:13:52 UTC

Dynamic Form Fields

Hi,

Currently, I have a DynaValidatorForm defined in my web app.  Some of
the properties of this form will be completely dynamic.  I will read a
database and retrieve an ArrayList.  This ArrayList will contain the
form field name, and form field value.  How do this with a
DynaValidatorForm?  Can I?

Any help would be MUCH appreciated...

Thanks,

Natalie


RE: Dynamic Form Fields

Posted by Alex Shneyderman <al...@law.columbia.edu>.
 
> Currently, I have a DynaValidatorForm defined in my web app.  Some of
> the properties of this form will be completely dynamic.  I will read a
> database and retrieve an ArrayList.  This ArrayList will contain the

If I understand you correctly 

for (Iterator iter = al.iterator (); iter.hasNext (); ) {
   Field f = (Field) iter.next ();
   myForm.set (f.getName (), f.getValue ());
}

In this case your form will have to be declared in struts-config.xml
Having all the possible f.getName () though, otherwise you will get
IllegalArgumentException. 

There is another method in DynaActionForm called getMap () this is your
map of key (name) / value pairs. I am not sure if it is mutable, I can't
see any setMap (), but you can try that out too.




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