You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Charlie Toohey <ct...@pacbell.net> on 2003/01/21 22:21:12 UTC

Re: DynaActionFormClass.getDynaActionFormClass >

Given the length of this thread and the effort people seem to be putting into 
instantiating their own forms, especialy Dyna*Form objects, I was wondering 
why people are doing this themselves rather than just letter ActionServlet 
(RequestProcessor) do it  when you have specified 
the form-bean name in the struts-config.xml mapping for that Action.

Is there some advantage to instantiating the form yourself, or is this just 
being done in special cases where people specifically do not want the form to 
be instantiated or they are dynamically creating ActionForm objects which are 
not defined in struts-config.xml, etc. etc.     Just wondering if I am 
missing something here.

- Charlie


On Wed, 8 Jan 2003, Franco Caponi wrote:

> Date: Wed, 8 Jan 2003 18:06:06 +0100
> From: Franco Caponi <fr...@tin.it>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: Struts Developers List <st...@jakarta.apache.org>
> Subject: Re: DynaActionFormClass.getDynaActionFormClass
>
> Hi Craig,
> I have tha same problem: from an Action class i need to create the
> ActionForm associated with a particular mapping and populate some properties
> before returning the correct ActionForward, but i don't know how call the
> suggested RequestUtils.createActionForm().
>
> My problem is how to supply the ActionMapping parameter because i have found
> only the findActionConfig on the ModuleConfig that return a superclass of
> ActionMapping.
>
> Calling it with a cast to ActionMapping generate a NullPointerException...
>

You should get a ClassCastException if this were really an instance type
problem.  Without the stack trace, it's impossible to know what is really
happening.

> Can you supply a simple example/ How to??
>

Here's an additional technique that is a little more work, but just starts
with a ModuleConfig and a form bean name.

  ModuleConfig mconfig = ... ModuleConfig for the current module
  FormBeanConfig fbconfig = mconfig.findFormBeanConfig("foo");
  DynaActionFormClass dafc =
    new DynaActionFormClass(fbconfig);
  DynaActionForm daf = dafc.newInstance();

> TIA
>

Craig

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>