On Wed, 23 Jan 2002, Ted Husted wrote:

> Date: Wed, 23 Jan 2002 18:10:07 -0500
> From: Ted Husted <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> To: Struts Developers List <[EMAIL PROTECTED]>
> Subject: Re: cvs commit: jakarta-struts/web/exercise-taglib/WEB-INF
>     web.xml
>
> Craig,
>
> I had thought this would be a useful way for Developers to chain actions
> without generating additional forwards. Do you disagree? Is there a
> problem with the implementation? I know some people have found it
> useful, and have made dependencies on it.
>

Chaining is unlikely to be significantly more efficient than request
dispatcher forwarding.  Also, beyond that, I do have a couple of
design/architecture concerns:

* Not using a RequestDispatcher.forward() means you don't get
  the container semantics of erasing any previously generated
  output (and complaining if you've already committed the response).
  Unless you simulate this -- which you could do with wrappers in
  Servlet 2.3 -- an action invoked this way sees different behavior
  than one invoked via an RD.

* In the early days of servlets (prior to the 2.0 spec) there was a
  feature of some containers called "servlet chaining", which differs
  in details from this but was the same idea in spirit -- seducing
  the developer into combining components in ways that were not the
  original intent.  People that used this technique tended to create
  spaghetti code that was very difficult to maintain.  I'd rather
  avoid that.

* Because using a request dispatcher flows back through the controller,
  we have the opportunity to "value add" new standard logic (such as
  role-based access)  before the forward is completed -- but chaining
  would bypass this.

I vote for maintaining the original design intent, and requiring actions
who want to invoke others to simply return an ActionForward that points at
another action, instead of a UI component.

> Or, did you just want to deal with it later? Should I take care of it
> now?
>
> -Ted.

Craig


>
> >   -    /**
> >   -     * Return an instance of the ActionForm associated with the specified
> >   -     * path, if any; otherwise return <code>null</code>.
> >   -     * May be used to create an ActionForm for InvokeAction.
> >   -     *
> >   -     * @param name path of the Action using the ActionForm bean
> >   -     * @since 1.1
> >   -     */
> >   -    public ActionForm createActionForm(String path) {
> >   -
> >   -        ActionMapping mapping = findMapping(path);
> >   -        String name = mapping.getName();
> >   -
> >   -        ActionForm form = null;
> >   -
> >   -        ActionFormBean formBean = findFormBean(name);
> >   -        if (formBean != null) {
> >   -            String className = null;
> >   -            className = formBean.getType();
> >   -            try {
> >   -                Class clazz = Class.forName(className);
> >   -                form = (ActionForm) clazz.newInstance();
> >   -            } catch (Throwable t) {
> >   -                form = null;
> >   -            }
> >   -        }
> >   -
> >   -        return form;
> >   -
> >   -    }
> >   -
> >   -
> >   -    /**
> >   -     * Directly process the Action perform associated with the
> >   -     * given path.
> >   -     * Return the <code>ActionForward</code> instance (if any)
> >   -     * returned by the called <code>Action</code>.
> >   -     * <code>createActionForm</code> may be used to create an
> >   -     * ActionForm instance to pass to the Action invoked.
> >   -     *
> >   -     * @param action The path to the Action to invoke
> >   -     * @param form The ActionForm we are processing
> >   -     * @param request The servlet request we are processing
> >   -     * @param response The servlet response we are creating
> >   -     *
> >   -     * @exception IOException if an input/output error occurs
> >   -     * @exception ServletException if a servlet exception occurs
> >   -     * @since 1.1
> >   -     */
> >   -    public ActionForward invokeAction(
> >   -            String path,
> >   -            ActionForm form,
> >   -            HttpServletRequest request,
> >   -            HttpServletResponse response)
> >   -        throws IOException, ServletException {
> >   -
> >   -        ActionMapping mapping =
> >   -            processMapping(path,request);
> >   -
> >   -        Action action =
> >   -            processActionCreate(mapping,request);
> >   -
> >   -        ActionForward forward = processActionPerform(
> >   -            action,mapping,form,request,response);
> >   -
> >   -        return forward;
> >   -
> >   -    }
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to