husted      01/12/16 08:50:10

  Modified:    src/share/org/apache/struts/action ActionServlet.java
  Log:
  Add InvokeAction and CreateActionForm methods to allow direct
  chaining of Actions, per discussions on DEV list.
  
  http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg03802.html
  
  Revision  Changes    Path
  1.79      +74 -4     
jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- ActionServlet.java        2001/12/16 16:45:13     1.78
  +++ ActionServlet.java        2001/12/16 16:50:10     1.79
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.78 
2001/12/16 16:45:13 husted Exp $
  - * $Revision: 1.78 $
  - * $Date: 2001/12/16 16:45:13 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.79 
2001/12/16 16:50:10 husted Exp $
  + * $Revision: 1.79 $
  + * $Date: 2001/12/16 16:50:10 $
    *
    * ====================================================================
    *
  @@ -233,7 +233,7 @@
    *
    * @author Craig R. McClanahan
    * @author Ted Husted
  - * @version $Revision: 1.78 $ $Date: 2001/12/16 16:45:13 $
  + * @version $Revision: 1.79 $ $Date: 2001/12/16 16:50:10 $
    */
   
   public class ActionServlet
  @@ -925,6 +925,76 @@
        */
       public void setTempDir(String tempDir) {
           this.tempDir = tempDir;
  +    }
  +
  +
  +    /**
  +     * 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]>

Reply via email to