webwork/src/main/webwork/action ActionSupport.java,1.29,1.30

[email protected] Thu, 30 May 2002 16:54:50 -0700
Newsgroups gmane.comp.java.webwork.cvs
Message-ID <[email protected]>
Update of /cvsroot/webwork/webwork/src/main/webwork/action
In directory usw-pr-cvs1:/tmp/cvs-serv27735

Modified Files:
	ActionSupport.java 
Log Message:
change scope of command

Index: ActionSupport.java
===================================================================
RCS file: /cvsroot/webwork/webwork/src/main/webwork/action/ActionSupport.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- ActionSupport.java	19 May 2002 02:36:15 -0000	1.29
+++ ActionSupport.java	30 May 2002 23:54:48 -0000	1.30
@@ -34,7 +34,7 @@
 
    protected Map errorMap;
    protected Collection errorMessages;
-   private String command;
+   protected String command;
 
 
    // IllegalFormatAware implementation -----------------------------
@@ -43,17 +43,17 @@
       addError(fieldName, e.getMessage());
    }
 
-	// CommandDriven implementation ----------------------------------
+   // CommandDriven implementation ----------------------------------
    /**
     * Support implementation of CommandDriven interface. Let your action
     * subclasses implement CommandDriven if they support this notion.
     *
     * @see CommandDriven
     */
-	public void setCommand(String command)
-	{
-		this.command = command;
-	}
+   public void setCommand(String command)
+   {
+      this.command = command;
+   }
 
    /**
     * Detect whether a particular command has been issued
@@ -95,20 +95,20 @@
          }
 
          // Check whether command is being invoked
-			if(command!=null && !command.equals("") && this instanceof CommandDriven)
-			{
-				return invokeCommand();
-			}
-			else
-			{
+         if(command!=null && !command.equals("") && this instanceof CommandDriven)
+         {
+            return invokeCommand();
+         }
+         else
+         {
             // Validate input data
             validate();
 
-				// Do main processing
-				return doExecute();
-			}
+            // Do main processing
+            return doExecute();
+         }
       }
-		catch (ResultException e)
+      catch (ResultException e)
       {
          return e.getResult();
       } finally
@@ -156,11 +156,11 @@
       return errorMessages != null && errorMessages.size() != 0;
    }
 
-	/**
-	 * Add an error message to this action
-	 *
-	 * @param   anErrorMessage
-	 */
+   /**
+    * Add an error message to this action
+    *
+    * @param   anErrorMessage
+    */
    public void addErrorMessage(String anErrorMessage)
    {
       if (errorMessages == null)
@@ -170,11 +170,11 @@
 
 
    /**
-	 * This method is used to attach an error message to a particular form field.
-	 *
-	 * @param   fieldName  name of field
-	 * @param   errorMessage  the error message
-	 */
+    * This method is used to attach an error message to a particular form field.
+    *
+    * @param   fieldName  name of field
+    * @param   errorMessage  the error message
+    */
    public void addError(String fieldName, String errorMessage)
    {
       if (errorMap == null)
@@ -183,11 +183,11 @@
    }
 
 
-	/**
-	 * Get the field specific errors associated with this action.
-	 *
-	 * @return     map with errors
-	 */
+   /**
+    * Get the field specific errors associated with this action.
+    *
+    * @return     map with errors
+    */
    public Map getErrors()
    {
       if (errorMap == null)
@@ -197,24 +197,24 @@
    }
 
 
-	/**
-	 * Check whether there are any errors associated with this action.
-	 *
-	 * @return     whether there are any errors
-	 */
+   /**
+    * Check whether there are any errors associated with this action.
+    *
+    * @return     whether there are any errors
+    */
    public boolean getHasErrors()
    {
       return errorMap != null;
    }
 
-	/**
-	 * Get the locale for this action.
+   /**
+    * Get the locale for this action.
     *
     * Applications may customize how locale is chosen by
     * subclassing ActionSupport and override this method.
-	 *
-	 * @return     the locale to use
-	 */
+    *
+    * @return     the locale to use
+    */
    public Locale getLocale()
    {
       return ActionContext.getContext().getLocale();
@@ -336,44 +336,44 @@
       return getHasErrorMessages() || getHasErrors();
    }
 
-	/**
-	 * Invokes an alternate execution path for the action. The name of the action
-	 * is derived by prepending a "do" and capitalizing the first letter of the
-	 * action.
-	 *
-	 */
-	protected String invokeCommand() throws Exception
-	{
-	   StringBuffer sb=new StringBuffer("do");
-		sb.append(command);
-		sb.setCharAt(2,Character.toUpperCase(sb.charAt(2)));
-		String cmd=sb.toString();
-		log.debug("Executing action with command="+command+" (mapped to method: "+cmd+")");
+   /**
+    * Invokes an alternate execution path for the action. The name of the action
+    * is derived by prepending a "do" and capitalizing the first letter of the
+    * action.
+    *
+    */
+   protected String invokeCommand() throws Exception
+   {
+      StringBuffer sb=new StringBuffer("do");
+      sb.append(command);
+      sb.setCharAt(2,Character.toUpperCase(sb.charAt(2)));
+      String cmd=sb.toString();
+      log.debug("Executing action with command="+command+" (mapped to method: "+cmd+")");
       Method method;
 
       try
       {
          method=getClass().getMethod(cmd,new Class[0]);
       }
-		catch (NoSuchMethodException e)
+      catch (NoSuchMethodException e)
       {
          throw new IllegalArgumentException("No command '"+command+"' in action");
       }
-	   try
-	   {
-      	return (String)method.invoke(this,new Object[0]);
-	   }
-	   catch(InvocationTargetException e)
-	   {
-		   /**
-		    * We try to return the source exception.
-		    */
-		   Throwable t=e.getTargetException();
-			if(t instanceof Exception)
-				throw (Exception)t;
-			throw e;
-		}
-	}
+      try
+      {
+         return (String)method.invoke(this,new Object[0]);
+      }
+      catch(InvocationTargetException e)
+      {
+         /**
+          * We try to return the source exception.
+          */
+         Throwable t=e.getTargetException();
+         if(t instanceof Exception)
+            throw (Exception)t;
+         throw e;
+      }
+   }
 
    private void readObject(java.io.ObjectInputStream stream)
         throws IOException, ClassNotFoundException



_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm