At 07:46 AM 8/6/2004, you wrote:
What I need to do is construct a form that has a
variety of text input forms on it that are determined
at run-time. I know how to do this in jsp but I need
to provide an ActionForm that conforms to that form.
I got several useful replies last night and am
investigating them.

Dean


Maybe something like:

<pre>

public class DynamicActionFormFactory {
/** This method is used to configure and create a new empty dynamic
* action form based on the parameters provided.
*
* @param name the registered name of the form
* @param type the name of the Java class of the form
* @param fields a list of the field names to be used in the form
* @return the modified String */
public static ActionForm createBlankForm(String name, String type, String[] fields) {
ActionForm form = null;
FormBeanConfig config = null;
FormPropertyConfig prop = null;


    config = new FormBeanConfig();
    config.setName(name);
    config.setType(type);

    if (fields != null) {
      for (int i=0; i<fields.length; i++) {
        prop = new FormPropertyConfig();
        prop.setName(fields[i]);
        prop.setType("java.lang.String");
        prop.setInitial("");
        prop.freeze();
        config.addFormPropertyConfig(prop);
      }
    }

    config.freeze();

try {
form = (ActionForm) DynaActionFormClass.createDynaActionFormClass(config).newInstance();
} catch (Exception e) {
StdOut.log("log.error",new ChainedException(e,"Exception creating blank form: " + e.getMessage()));
}


    return form;
  }
}
</pre>

Michael McGrady




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



Reply via email to