niallp 2004/06/08 17:25:34 Modified: src/share/org/apache/struts/config FormBeanConfig.java Log: Changes for bug 28668/22207 Revision Changes Path 1.14 +72 -4 jakarta-struts/src/share/org/apache/struts/config/FormBeanConfig.java Index: FormBeanConfig.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/FormBeanConfig.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- FormBeanConfig.java 8 Apr 2004 22:07:56 -0000 1.13 +++ FormBeanConfig.java 9 Jun 2004 00:25:34 -0000 1.14 @@ -25,6 +25,9 @@ import java.io.Serializable; import java.util.HashMap; import org.apache.struts.action.DynaActionForm; +import org.apache.struts.action.DynaActionFormClass; +import org.apache.struts.action.ActionServlet; +import org.apache.struts.action.ActionForm; /** @@ -55,10 +58,40 @@ protected HashMap formProperties = new HashMap(); + /** + * <p>The lockable object we can synchronize on when creating DynaActionFormClass.</p> + */ + protected String lock = ""; + + // ------------------------------------------------------------- Properties /** + * The DynaActionFormClass associated with a DynaActionForm + */ + protected transient DynaActionFormClass dynaActionFormClass; + + /** + * <p>Return the DynaActionFormClass associated with a DynaActionForm</p> + * + * @exception IllegalArgumentException if the ActionForm is not dynamic + */ + public DynaActionFormClass getDynaActionFormClass() { + + if (dynamic == false) { + throw new IllegalArgumentException("ActionForm is not dynamic"); + } + synchronized (lock) { + if (dynaActionFormClass == null) { + dynaActionFormClass = new DynaActionFormClass(this); + } + } + return dynaActionFormClass; + } + + + /** * Is the form bean class an instance of DynaActionForm with dynamic * properties? */ @@ -129,6 +162,41 @@ // --------------------------------------------------------- Public Methods + + + /** + * <p>Create and return an <code>ActionForm</code> instance appropriate + * to the information in this <code>FormBeanConfig</code>.</p> + * + * @param servlet The action servlet + * @return ActionForm instance + * @exception IllegalAccessException if the Class or the appropriate + * constructor is not accessible + * @exception InstantiationException if this Class represents an abstract + * class, an array class, a primitive type, or void; or if instantiation + * fails for some other reason + */ + public ActionForm createActionForm(ActionServlet servlet) + throws IllegalAccessException, InstantiationException { + + ActionForm instance = null; + + // Create and return a new form bean instance + if (getDynamic()) { + + instance = (ActionForm)getDynaActionFormClass().newInstance(); + + } else { + + instance = (ActionForm)formBeanClass().newInstance(); + + } + + instance.setServlet(servlet); + + return (instance); + + } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]