On 7/15/05, Schaub, Stephen <[EMAIL PROTECTED]> wrote:
> 
> > -----Original Message-----
> > From: Ted Husted [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, July 13, 2005 3:22 PM
> > To: Struts Users Mailing List
> > Subject: Re: Putting execute() in ActionForm
> >
> > [snip]
> >
> > If I were to use this strategy, I'd select the parameters to the
> > Execute signature with care. There may not be any reason to pass the
> > HTTP parameters out of the call, and there may be a reason  to pass
> > the Action. I would just be careful of using the parameters from the
> > Struts Execute signature, unless my code actually needed those
> > parameters..
> 
> I have found that I do need the Action available to the ActionForm's execute 
> method, because the Action class contains several important utility methods 
> (like saveErrors(), etc.) that need to be available to the ActionForm's 
> execute method.
> 
> Further, since there is a separate ActionForm instance for each thread, I've 
> considered adding the ActionMapping and HttpServletRequest as instance 
> variables on the ActionForm, which are populated by the Action method before 
> invoking ActionForm.execute():
> 
> public class SimpleAction extends Action {
>   public ActionForward execute(ActionMapping mapping, ActionForm form,
>         HttpServletRequest request, HttpServletResponse response)
>         throws Exception {
>                 SimpleActionForm bean = (SimpleActionForm) form;
>                 bean.init(this, mapping, request);
>                 return bean.execute();
>       }
> }

You can do the same in ActionForm.reset(). It receives mapping and
request. I often pull out session object out of request and save it in
a field of an ActionForm, so I could access it outside reset().

> By the way, I'm very interested in all of the feedback on my request for 
> input on this
> pattern.  If this is considered a desirable pattern, would it be worth adding 
> it on the 
> Struts wiki?

Darn, I realised that I need another event for my CRUDAction, thus I
need another handler in the action, then I need to pass it to the
form, so I need to update ICRUDForm interface... If I called some kind
of execute() method in ActionForm directly, I would not have to change
the interface now.

So, I guess I will change the way Struts Dialogs works, and will
channel events directly to ActionForm. Instead of creating a new
generic traffic cop action I have to fiddle with some core class like
RequestProcessor. If action class is not defined for a form, and form
implements something like ICallable, then I would call form directly.

Major change... Good, that it had not been accepted to core Struts yet ;-)

Michael.

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

Reply via email to