husted      02/01/01 05:44:05

  Modified:    contrib/scaffold/src/framework/main/org/apache/scaffold/http
                        ContinueAction.java HelperAction.java
                        MasterDetailHelper.java ModelHelper.java
                        RelayAction.java
  Added:       contrib/scaffold/src/framework/main/org/apache/scaffold/http
                        BaseHelperAction.java FindForwardAction.java
                        RemoveAttribute.java SetModelHelper.java
  Log:
  + Modified ModelHelper to extend BaseHelperAction
  + Added BaseHelperAction
  + ModelDetailHelper - update JavaDocs.
  + Added SetModelHelper - standard action to set ModelBean as session attribute.
  + Added RemoveModelHelper - standard action to remove session attribute.
  + Added FindForwardAction - Scan parameters for a matching forward name.
  + ModelResult, ModelResultBase - Change parameter names in signature.
  
  Revision  Changes    Path
  1.3       +7 -7      
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ContinueAction.java
  
  Index: ContinueAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ContinueAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContinueAction.java       28 Dec 2001 13:34:57 -0000      1.2
  +++ ContinueAction.java       1 Jan 2002 13:44:04 -0000       1.3
  @@ -21,8 +21,8 @@
    * Useful for prototyping flow during development,
    * and for creating blank forms for new input.
    * @author Ted Husted
  - * @version $Revision: 1.2 $ $Date: 2001/12/28 13:34:57 $
  - */
  + * @version $Revision: 1.3 $ $Date: 2002/01/01 13:44:04 $
  +**/
   public final class ContinueAction extends Action {
   
       /**
  @@ -32,7 +32,7 @@
        * @param response The HTTP response we are creating
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception occurs
  -     */
  +    **/
       public ActionForward perform(ActionMapping mapping,
                    ActionForm form,
                    HttpServletRequest request,
  @@ -47,9 +47,9 @@
   
   
   /*
  - * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ContinueAction.java,v
 1.2 2001/12/28 13:34:57 vmassol Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/12/28 13:34:57 $
  + * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ContinueAction.java,v
 1.3 2002/01/01 13:44:04 husted Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/01 13:44:04 $
    *
    * ====================================================================
    *
  @@ -105,7 +105,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - */
  +**/
   
   
   
  
  
  
  1.3       +12 -12    
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/HelperAction.java
  
  Index: HelperAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/HelperAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HelperAction.java 28 Dec 2001 13:34:57 -0000      1.2
  +++ HelperAction.java 1 Jan 2002 13:44:04 -0000       1.3
  @@ -41,8 +41,8 @@
    * and an error condition is detected.
    * <p>
    * @author Ted Husted
  - * @version $Revision: 1.2 $ $Date: 2001/12/28 13:34:57 $
  - */
  + * @version $Revision: 1.3 $ $Date: 2002/01/01 13:44:04 $
  +**/
   public class HelperAction extends Action {
   
   
  @@ -54,7 +54,7 @@
        * is returned.
        * @author  François Rey (FREY - [EMAIL PROTECTED])
        * @author  Eric Bariaux (EBRX - [EMAIL PROTECTED])
  -     */
  +    **/
       public Locale getLocale(HttpServletRequest request) {
           Locale result = null;
           HttpSession session = request.getSession();
  @@ -70,7 +70,7 @@
   
       /**
        * Return the application resources for this web application, if any.
  -     */
  +    **/
       public MessageResources getMessageResources() {
           return servlet.getResources();
       }
  @@ -79,14 +79,14 @@
       /**
        * Number of replacement parameters permitted in Struts 1.0.
        * See also saveConfirm.
  -     */
  +    **/
       public static int CONFIRM_MAX = 5; // (Message Key, plus 1..4)
   
   
       /**
        * Retrieves a base messages and up to four replaceable
        * parameters from a List, and adds them as an ActionError.
  -     */
  +    **/
       public boolean saveMessage(ActionErrors errors, List messages) {
           if ((messages==null) || (messages.size()==0)) {
               return false;
  @@ -138,7 +138,7 @@
        * @param helper The object instantiated from type given as parameter.
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception occurs
  -     */
  +    **/
       public ActionForward perform(ActionMapping mapping,
                    ActionForm form,
                    HttpServletRequest request,
  @@ -169,7 +169,7 @@
        * <p>
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception occurs
  -     */
  +    **/
       public ActionForward perform(ActionMapping mapping,
                    ActionForm form,
                    HttpServletRequest request,
  @@ -219,9 +219,9 @@
   
   
   /*
  - * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/HelperAction.java,v
 1.2 2001/12/28 13:34:57 vmassol Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/12/28 13:34:57 $
  + * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/HelperAction.java,v
 1.3 2002/01/01 13:44:04 husted Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/01 13:44:04 $
    *
    * ====================================================================
    *
  @@ -277,4 +277,4 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - */
  +**/
  
  
  
  1.3       +11 -10    
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/MasterDetailHelper.java
  
  Index: MasterDetailHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/MasterDetailHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MasterDetailHelper.java   28 Dec 2001 13:34:57 -0000      1.2
  +++ MasterDetailHelper.java   1 Jan 2002 13:44:04 -0000       1.3
  @@ -20,20 +20,22 @@
    * retrieves detail based on the master. (A field in the
    * master record would usually match a field in the detail.)
    * @author Ted Husted
  - * @version $Revision: 1.2 $ $Date: 2001/12/28 13:34:57 $
  - */
  + * @version $Revision: 1.3 $ $Date: 2002/01/01 13:44:04 $
  +**/
   public class MasterDetailHelper extends ModelHelper {
   
   
       /**
  +     * Execute master helper, and use the result to obtain the detail.
  +     * Return master in ActionForm, and detail as ModelResult.
        * @param mapping The ActionMapping used to select this instance
        * @param actionForm The optional ActionForm bean for this request (if any)
        * @param request The HTTP request we are processing
        * @param helpers The helper objects
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception occurs
  -     */
  -    public ModelResult getResult(ActionMapping mapping,
  +    **/
  +    protected ModelResult getResult(ActionMapping mapping,
                    ActionForm form,
                    HttpServletRequest request,
                    HttpServletResponse response,
  @@ -53,14 +55,13 @@
   
       }
   
  -
  -} // end ModelResultHelper
  +} // end MasterDetailHelper
   
   
   /*
  - * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/MasterDetailHelper.java,v
 1.2 2001/12/28 13:34:57 vmassol Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/12/28 13:34:57 $
  + * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/MasterDetailHelper.java,v
 1.3 2002/01/01 13:44:04 husted Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/01 13:44:04 $
    *
    * ====================================================================
    *
  @@ -88,7 +89,7 @@
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
  - * 4. The names "The Jakarta Project", "Scaffold", and "Apache Software
  + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
    *    from this software without prior written permission. For written
    *    permission, please contact [EMAIL PROTECTED]
  @@ -116,7 +117,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - */
  +**/
   
   
   
  
  
  
  1.3       +39 -14    
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ModelHelper.java
  
  Index: ModelHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ModelHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModelHelper.java  28 Dec 2001 13:34:57 -0000      1.2
  +++ ModelHelper.java  1 Jan 2002 13:44:04 -0000       1.3
  @@ -25,9 +25,9 @@
   /**
    * Standard Action to manage helper objects.
    * @author Ted Husted
  - * @version $Revision: 1.2 $ $Date: 2001/12/28 13:34:57 $
  - */
  -public class ModelHelper extends HelperAction {
  + * @version $Revision: 1.3 $ $Date: 2002/01/01 13:44:04 $
  +**/
  +public class ModelHelper extends BaseHelperAction {
   
   
       /**
  @@ -38,8 +38,8 @@
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception occurs
        * :FIXME: is there any valid use of the response here?
  -     */
  -    public ModelResult getResult(ActionMapping mapping,
  +    **/
  +    protected ModelResult getResult(ActionMapping mapping,
                    ActionForm form,
                    HttpServletRequest request,
                    HttpServletResponse response,
  @@ -59,12 +59,35 @@
        * @param mapping The ActionMapping used to select this instance
        * @param actionForm The optional ActionForm bean for this request (if any)
        * @param request The HTTP request we are processing
  +     * @param helper The helper object
  +     * @exception IOException if an input/output error occurs
  +     * @exception ServletException if a servlet exception occurs
  +     * :FIXME: is there any valid use of the response here?
  +    **/
  +     protected ActionForward getContinue(
  +         ActionMapping mapping,
  +         ActionForm form,
  +         HttpServletRequest request,
  +         HttpServletResponse response,
  +         Object[] helpers
  +         ) throws IOException, ServletException {
  +
  +        // return mapping.findForward(request.getParameter(Tokens.FORWARD));
  +        return mapping.findForward(Tokens.CONTINUE);
  +
  +    }
  +
  +
  +    /**
  +     * @param mapping The ActionMapping used to select this instance
  +     * @param actionForm The optional ActionForm bean for this request (if any)
  +     * @param request The HTTP request we are processing
        * @param response The HTTP response we are creating
        * @param helper The helper object
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception occurs
  -     */
  -    public ActionForward perform(ActionMapping mapping,
  +    **/
  +    protected ActionForward perform(ActionMapping mapping,
                    ActionForm form,
                    HttpServletRequest request,
                    HttpServletResponse response,
  @@ -100,7 +123,7 @@
               if (mapping.getInput()!=null)
                   return (new ActionForward(mapping.getInput()));
               // If no input page, use error forwarding
  -            return (mapping.findForward("error"));
  +            return (mapping.findForward(Tokens.ERROR));
           }
   
           // -- Check for confirmation message
  @@ -120,16 +143,18 @@
               forward = mapping.findForward(Tokens.EMPTY);
           if (forward!=null)
               return forward;
  -        return mapping.findForward(Tokens.CONTINUE);
  -    };
  +
  +        // -- Return forward for successful outcome
  +        return getContinue(mapping,form,request,response,helpers);
  +    }
   
   } // end ModelResultHelper
   
   
   /*
  - * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ModelHelper.java,v
 1.2 2001/12/28 13:34:57 vmassol Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/12/28 13:34:57 $
  + * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/ModelHelper.java,v
 1.3 2002/01/01 13:44:04 husted Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/01 13:44:04 $
    *
    * ====================================================================
    *
  @@ -157,7 +182,7 @@
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
  - * 4. The names "The Jakarta Project", "Scaffold", and "Apache Software
  + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
    *    from this software without prior written permission. For written
    *    permission, please contact [EMAIL PROTECTED]
  @@ -185,7 +210,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - */
  +**/
   
   
   
  
  
  
  1.3       +7 -7      
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/RelayAction.java
  
  Index: RelayAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/RelayAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RelayAction.java  28 Dec 2001 13:34:57 -0000      1.2
  +++ RelayAction.java  1 Jan 2002 13:44:04 -0000       1.3
  @@ -20,8 +20,8 @@
    * Standard Action to forward control to another mapping
    * given as a runtime parameter (?forward=).
    * @author Ted Husted
  - * @version $Revision: 1.2 $ $Date: 2001/12/28 13:34:57 $
  - */
  + * @version $Revision: 1.3 $ $Date: 2002/01/01 13:44:04 $
  +**/
   public final class RelayAction extends Action {
   
       /**
  @@ -31,7 +31,7 @@
        * @param response The HTTP response we are creating
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception occurs
  -     */
  +    **/
       public ActionForward perform(ActionMapping mapping,
                    ActionForm form,
                    HttpServletRequest request,
  @@ -46,9 +46,9 @@
   
   
   /*
  - * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/RelayAction.java,v
 1.2 2001/12/28 13:34:57 vmassol Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/12/28 13:34:57 $
  + * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/RelayAction.java,v
 1.3 2002/01/01 13:44:04 husted Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/01 13:44:04 $
    *
    * ====================================================================
    *
  @@ -104,7 +104,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - */
  +**/
   
   
   
  
  
  
  1.1                  
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/BaseHelperAction.java
  
  Index: BaseHelperAction.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.List;
  import java.util.Locale;
  import java.util.StringTokenizer;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionError;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  import org.apache.struts.util.MessageResources;
  
  import org.apache.scaffold.lang.Tokens;
  
  
  /**
   * Base class to instantiate helper objects from
   * parameter mapping. Subclasses should
   * override the alternate perform to provide
   * functionality. The standard perform will
   * instantiate the object, and call the
   * other perform method.
   * <p>
   * Multiple helper classes may be specified in a
   * comma delimited list, which will be instantiated
   * in the helpers array in the order given.
   * <p>
   * Will also look for cancel and token mappings,
   * and automatically redirect if those are present
   * and an error condition is detected.
   * <p>
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2002/01/01 13:44:04 $
  **/
  public class BaseHelperAction extends Action {
  
  
  // --------------------------------------------------------- Public Methods
  
      /**
       * Return the locale for the given request. If no session is set,
       * or if the session has no locale set, the default locale
       * is returned.
       * @author  François Rey (FREY - [EMAIL PROTECTED])
       * @author  Eric Bariaux (EBRX - [EMAIL PROTECTED])
      **/
      protected Locale getLocale(HttpServletRequest request) {
          Locale result = null;
          HttpSession session = request.getSession();
          if (session!=null) {
              result = (Locale) session.getAttribute(Action.LOCALE_KEY);
              if (result == null) result = Locale.getDefault();
          } else {
              result = Locale.getDefault();
          }
          return result;
      }
  
  
      /**
       * Return the application resources for this web application, if any.
      **/
      public MessageResources getMessageResources() {
          return servlet.getResources();
      }
  
  
      /**
       * Number of replacement parameters permitted in Struts 1.0.
       * See also saveConfirm.
      **/
      public static int CONFIRM_MAX = 5; // (Message Key, plus 1..4)
  
  
      /**
       * Retrieves a base messages and up to four replaceable
       * parameters from a List, and adds them as an ActionError.
      **/
      protected boolean saveMessage(ActionErrors errors, List messages) {
          if ((messages==null) || (messages.size()==0)) {
              return false;
          }
          int size = messages.size();
              // Struts 1.0 allows up to 4 parameters, 1..4
          if (size > CONFIRM_MAX) size = CONFIRM_MAX;
          String[] confirm = new String[size];
          for (int i=0; i<size; i++) {
              confirm[i] = (String) messages.get(i);
          }
          switch (size) {
             case 5:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1],confirm[2],confirm[3],confirm[4]));
                  break;
             case 4:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1],confirm[2],confirm[3]));
                  break;
             case 3:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1],confirm[2]));
                  break;
             case 2:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1]));
                  break;
             case 1:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0]));
          }
          return true;
      }
  
  
      /**
       * Simple test to render String version of instantiated
       * helpers. Should be overridden to provide functionality
       * (without calling super!).
       * @param mapping The ActionMapping used to select this instance
       * @param form The ActionForm
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * @param helper The object instantiated from type given as parameter.
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
      **/
      protected ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   Object[] helpers)
      throws IOException, ServletException {
          // override to provide new functionality
          response.setContentType("text/plain");
          for (int i = 0; i < helpers.length; i++)
              response.getWriter().print(helpers[i].toString());
          return (null);
      }
  
  
      /**
       * Instantiate helper objects from the type given as the
       * ActionMapping parameter (delimited with semicolons), and call
       * the alternate perform.
       * Will not call "helper" perform if helper creation fails.
       * The error is logged, and null returned.
       * <p>
       * Also checks for cancel and token conditions, if an
       * appropriate forward is present.
       * @param mapping The ActionMapping used to select this instance
       * @param form The ActionForm
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * <p>
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
      **/
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
      throws IOException, ServletException {
  
          // Check for cancelled
          ActionForward forward = mapping.findForward(Tokens.CANCEL);
          if ((forward!=null) && (isCancelled(request))) {
              return (forward);
          }
  
          // Check for missing token
          forward = mapping.findForward(Tokens.TOKEN);
          if ((forward!=null) && (!isTokenValid(request))) {
              return (forward);
          }
  
          // This creates a helper for each request.
          // Using data fields in the helper object is thread safe.
          StringTokenizer helperClasses =
              new StringTokenizer(mapping.getParameter(),";");
          int i = -1;
          Object[] helpers = new Object[helperClasses.countTokens()];
          while (helperClasses.hasMoreTokens()) {
              String helperClass = helperClasses.nextToken().trim();
              if ((helperClass==null) || (helperClass.length()==0)) continue;
              servlet.log("  Creating Helper for class " + helperClass,1);
              try {
                  helpers[++i] = Class.forName(helperClass).newInstance();
              } catch (Throwable t) {
                  servlet.log("Error creating Helper instance for path '" +
                  mapping.getPath() + "', class name '" +
                  helperClass + "'",t);
                  return (null);
              }
              servlet.log("  Helper created " + helperClass,2);
              // Pass control to alternate perform
              // which should be overridden by subclass.
          }
  
          return perform(mapping,form,request,response,helpers);
  
      } // end perform
  
  } // end BaseHelperAction
  
  
  /*
   * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/BaseHelperAction.java,v
 1.1 2002/01/01 13:44:04 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/01 13:44:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
  **/
  
  
  
  1.1                  
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/FindForwardAction.java
  
  Index: FindForwardAction.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  
  import org.apache.scaffold.lang.Tokens;
  
  
  /**
   * Scan request parameters for the name of a local or global
   * forward. If one is found, use it. If not, return null.
   * @author Dmitri Valdin
   * @version $Revision: 1.1 $ $Date: 2002/01/01 13:44:04 $
  **/
  public final class FindForwardAction extends Action {
  
      /**
       * Scan request parameters for the name of a local or global
       * forward. If one is found, use it. If not, return null.
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
      **/
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
      throws IOException, ServletException {
  
          String forwards[] = mapping.findForwards();
          for (int i=0; i<forwards.length; i++) {
              if (request.getParameter(forwards[i])!=null) {
                   // Return the required ActionForward instance
                   return mapping.findForward(forwards[i]);
               }
           }
  
          return null;
  
          /*
          int count=0;
          ActionForward forward = null;
          for (int i=0; i<forwards.length; i++) {
              if (request.getParameter(forwards[i])!=null) {
                  forward = mapping.findForward(forwards[i]);
                  count++;
               }
           }
  
          if (count>1) {
              // duplicate forward error
          }
  
          return forward;
         **/
      }
  
  } // end FindForwardAction
  
  /*
   * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/FindForwardAction.java,v
 1.1 2002/01/01 13:44:04 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/01 13:44:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
  **/
  
  
  
  
  
  
  
  1.1                  
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/RemoveAttribute.java
  
  Index: RemoveAttribute.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  
  import org.apache.scaffold.lang.Tokens;
  
  
  /**
   * Remove an object from the user's session.
   * The name of the attribute is passed via the parameter property.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2002/01/01 13:44:04 $
  **/
  public final class RemoveAttribute extends Action {
  
      /**
       * Remove an object from the user's session.
       * The name of the attribute is passed via the parameter property.
       * <p>
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
      **/
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
      throws IOException, ServletException {
  
         request.getSession().removeAttribute(
             mapping.getParameter());
         return mapping.findForward(Tokens.CONTINUE);
  
      }
  
  } // end RemoveHelper
  
  
  /*
   * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/RemoveAttribute.java,v
 1.1 2002/01/01 13:44:04 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/01 13:44:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  
  
  
  1.1                  
jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/SetModelHelper.java
  
  Index: SetModelHelper.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  import org.apache.scaffold.http.ModelHelper;
  import org.apache.scaffold.model.ModelException;
  import org.apache.scaffold.model.ModelResult;
  
  
  /**
   * Sets helper object as a session attribute.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2002/01/01 13:44:04 $
  **/
  public class SetModelHelper extends ModelHelper {
  
  
      /**
       * Standard Action to set a ModelBean helper as a session attribute,
       * using the helper type as the attribute key,
       * and then execute the ModelBean.
       * <p>
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param helper The helper object
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       * :FIXME: is there any valid use of the response here?
      **/
      public ModelResult getResult(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   Object[] helpers) throws ModelException {
  
         request.getSession().setAttribute(mapping.getParameter(),helpers[0]);
         return super.getResult(mapping,form,request,response,helpers);
  
      }
  
  } // end SessionModelHelper
  
  
  /*
   * $Header: 
/home/cvs/jakarta-struts/contrib/scaffold/src/framework/main/org/apache/scaffold/http/SetModelHelper.java,v
 1.1 2002/01/01 13:44:04 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/01 13:44:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
  **/
  
  
  
  
  
  
  

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

Reply via email to