You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/01/21 01:21:00 UTC
svn commit: r370938 [7/50] - in /struts: action/trunk/
action/trunk/conf/java/ action/trunk/src/java/org/apache/struts/
action/trunk/src/java/org/apache/struts/action/
action/trunk/src/java/org/apache/struts/chain/
action/trunk/src/java/org/apache/stru...
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java Fri Jan 20 16:19:02 2006
@@ -13,54 +13,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ActionConfig;
-
/**
* <p>Create (if necessary) and cache an <code>Action</code> for this request.
* </p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public abstract class AbstractCreateAction extends ActionCommandBase {
-
-
// ------------------------------------------------------ Instance Variables
- private static final Log log =
+ private static final Log log =
LogFactory.getLog(AbstractCreateAction.class);
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Create (if necessary) and cache an <code>Action</code> for this
* request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Skip processing if the current request is not valid
Boolean valid = actionCtx.getFormValid();
+
if ((valid == null) || !valid.booleanValue()) {
log.trace("Invalid form; not going to execute.");
+
return (false);
}
// Check to see if an action has already been created
if (actionCtx.getAction() != null) {
- log.trace("already have an action [" + actionCtx.getAction() + "]");
+ log.trace(
+ "already have an action [" + actionCtx.getAction() + "]");
+
return (false);
}
@@ -70,41 +67,39 @@
if (type == null) {
log.trace("no type for " + actionConfig.getPath());
+
return (false);
}
// Create (if necessary) and cache an Action instance
Action action = getAction(actionCtx, type, actionConfig);
+
if (log.isTraceEnabled()) {
log.trace("setting action to " + action);
}
+
actionCtx.setAction(action);
return (false);
-
}
-
// ------------------------------------------------------- Protected Methods
-
/**
- * Create and return the appropriate <code>Action</code> class for the
+ * Create and return the appropriate <code>Action</code> class for the
* given <code>type</code> and <code>actionConfig</code>.
+ *
* @param context
* @param type
* @param actionConfig
* @return
- * @throws Exception if there are any problems instantiating the Action
- * class.
- * @todo The dependence on ActionServlet suggests that this should be
- * broken up along the lines of the other Abstract/concrete pairs in the
+ * @throws Exception if there are any problems instantiating the Action
+ * class.
+ * @todo The dependence on ActionServlet suggests that this should be
+ * broken up along the lines of the other Abstract/concrete pairs in the
* org.apache.struts.chain.commands package.
*/
- protected abstract Action getAction(ActionContext context,
- String type,
- ActionConfig actionConfig)
+ protected abstract Action getAction(ActionContext context, String type,
+ ActionConfig actionConfig)
throws Exception;
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java Fri Jan 20 16:19:02 2006
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.chain.contexts.ActionContext;
@@ -25,46 +23,38 @@
import org.apache.struts.config.ForwardConfig;
import org.apache.struts.config.ModuleConfig;
-
/**
* <p>Invoke the local or global exception handler configured for the
* exception class that occurred.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public abstract class AbstractExceptionHandler extends ActionCommandBase {
-
-
// ------------------------------------------------------ Instance Variables
-
-
private static final Log log =
- LogFactory.getLog(AbstractExceptionHandler.class);
-
-
+ LogFactory.getLog(AbstractExceptionHandler.class);
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Invoke the appropriate <code>Action</code> for this request, and cache
- * the returned <code>ActionForward</code>.</p>
+ * <p>Invoke the appropriate <code>Action</code> for this request, and
+ * cache the returned <code>ActionForward</code>.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
- * @exception InvalidPathException if no valid
- * action can be identified for this request
- *
* @return <code>false</code> if a <code>ForwardConfig</code> is returned,
- * else <code>true</code> to complete processing
+ * else <code>true</code> to complete processing
+ * @throws InvalidPathException if no valid action can be identified for
+ * this request
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Look up the exception that was thrown
Exception exception = actionCtx.getException();
+
if (exception == null) {
log.warn("No Exception found in ActionContext");
+
return (true);
}
@@ -73,22 +63,24 @@
ActionConfig actionConfig = actionCtx.getActionConfig();
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
-
if (actionConfig != null) {
if (log.isDebugEnabled()) {
- log.debug("See if actionConfig " + actionConfig
- + " has an exceptionConfig for "
+ log.debug("See if actionConfig " + actionConfig
+ + " has an exceptionConfig for "
+ exception.getClass().getName());
}
+
exceptionConfig =
- actionConfig.findException(exception.getClass());
+ actionConfig.findException(exception.getClass());
} else if (moduleConfig != null) {
if (log.isDebugEnabled()) {
- log.debug("No action yet, see if moduleConfig " + moduleConfig
- + " has an exceptionConfig "
+ log.debug("No action yet, see if moduleConfig " + moduleConfig
+ + " has an exceptionConfig "
+ exception.getClass().getName());
}
- exceptionConfig = moduleConfig.findException(exception.getClass());
+
+ exceptionConfig =
+ moduleConfig.findException(exception.getClass());
}
// Handle the exception in the configured manner
@@ -96,39 +88,36 @@
log.warn("Unhandled exception", exception);
throw exception;
}
- ForwardConfig forwardConfig =
- handle(actionCtx, exception, exceptionConfig,
- actionConfig, moduleConfig);
+
+ ForwardConfig forwardConfig = handle(actionCtx, exception,
+ exceptionConfig, actionConfig, moduleConfig);
+
if (forwardConfig != null) {
actionCtx.setForwardConfig(forwardConfig);
+
return (false);
} else {
return (true);
}
-
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Perform the required handling of the specified exception.</p>
*
- * @param context The <code>Context</code> for this request
- * @param exception The exception being handled
+ * @param context The <code>Context</code> for this request
+ * @param exception The exception being handled
* @param exceptionConfig The corresponding {@link ExceptionConfig}
- * @param actionConfig The {@link ActionConfig} for this request
- * @param moduleConfig The {@link ModuleConfig} for this request
- *
+ * @param actionConfig The {@link ActionConfig} for this request
+ * @param moduleConfig The {@link ModuleConfig} for this request
* @return the <code>ForwardConfig</code> to be processed next (if any),
- * or <code>null</code> if processing has been completed
+ * or <code>null</code> if processing has been completed
*/
protected abstract ForwardConfig handle(ActionContext context,
Exception exception,
ExceptionConfig exceptionConfig,
ActionConfig actionConfig,
ModuleConfig moduleConfig)
- throws Exception;
-
+ throws Exception;
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java Fri Jan 20 16:19:02 2006
@@ -13,87 +13,77 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ActionConfig;
import org.apache.struts.config.ForwardConfig;
-
/**
* <p>Invoke the appropriate <code>Action</code> for this request, and cache
* the returned <code>ActionForward</code>.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
+ * $
*/
-
public abstract class AbstractExecuteAction extends ActionCommandBase {
-
-
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Invoke the appropriate <code>Action</code> for this request, and cache
- * the returned <code>ActionForward</code>.</p>
+ * <p>Invoke the appropriate <code>Action</code> for this request, and
+ * cache the returned <code>ActionForward</code>.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
- * @exception InvalidPathException if no valid
- * action can be identified for this request
- *
* @return <code>false</code> so that processing continues
+ * @throws InvalidPathException if no valid action can be identified for
+ * this request
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Skip processing if the current request is not valid
Boolean valid = actionCtx.getFormValid();
+
if ((valid == null) || !valid.booleanValue()) {
return (false);
}
// Acquire the resources we will need to send to the Action
Action action = actionCtx.getAction();
+
if (action == null) {
return (false);
}
+
ActionConfig actionConfig = actionCtx.getActionConfig();
ActionForm actionForm = actionCtx.getActionForm();
// Execute the Action for this request, caching returned ActionForward
- ForwardConfig forwardConfig =
- execute(actionCtx, action, actionConfig, actionForm);
+ ForwardConfig forwardConfig = execute(actionCtx, action, actionConfig,
+ actionForm);
+
actionCtx.setForwardConfig(forwardConfig);
return (false);
-
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Execute the specified <code>Action</code>, and return the resulting
* <code>ForwardConfig</code>.</p>
*
- * @param context The <code>Context</code> for this request
- * @param action The <code>Action</code> to be executed
+ * @param context The <code>Context</code> for this request
+ * @param action The <code>Action</code> to be executed
* @param actionConfig The <code>ActionConfig</code> defining this action
- * @param actionForm The <code>ActionForm</code> (if any) for
- * this action
- *
- * @exception Exception if thrown by the <code>Action</code>
+ * @param actionForm The <code>ActionForm</code> (if any) for this
+ * action
+ * @throws Exception if thrown by the <code>Action</code>
*/
protected abstract ForwardConfig execute(ActionContext context,
Action action,
ActionConfig actionConfig,
ActionForm actionForm)
- throws Exception;
-
-
+ throws Exception;
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java Fri Jan 20 16:19:02 2006
@@ -13,64 +13,53 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ForwardConfig;
-
/**
* <p>Perform forwarding or redirection based on the specified
* <code>ForwardConfig</code> (if any).</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
+ * $
*/
-
public abstract class AbstractPerformForward extends ActionCommandBase {
-
-
-
-
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Perform forwarding or redirection based on the specified
* <code>ActionForward</code> (if any).</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>true</code> so that processing completes
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Is there a ForwardConfig to be performed?
ForwardConfig forwardConfig = actionCtx.getForwardConfig();
+
if (forwardConfig == null) {
return (false);
}
// Perform the appropriate processing on this ActionForward
perform(actionCtx, forwardConfig);
- return (true);
+ return (true);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Perform the appropriate processing on the specified
* <code>ForwardConfig</code>.</p>
*
- * @param context The context for this request
+ * @param context The context for this request
* @param forwardConfig The forward to be performed
*/
protected abstract void perform(ActionContext context,
ForwardConfig forwardConfig)
- throws Exception;
-
-
+ throws Exception;
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java Fri Jan 20 16:19:02 2006
@@ -13,40 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ModuleConfig;
-
/**
* <p>Perform forwarding or redirection based on the specified
* <code>String</code> (if any).</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
+ * $
*/
-
public abstract class AbstractPerformInclude extends ActionCommandBase {
-
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Perform an include based on the specified
- * include uri (if any).</p>
+ * <p>Perform an include based on the specified include uri (if any).</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>true</code> so that processing completes
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
// Is there an include to be performed?
String include = actionCtx.getInclude();
+
if (include == null) {
return (false);
}
@@ -56,24 +50,19 @@
// Perform the appropriate processing on this include uri
perform(actionCtx, uri);
- return (true);
+ return (true);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
- * <p>Perform the appropriate processing on the specified
- * include uri.</p>
+ * <p>Perform the appropriate processing on the specified include
+ * uri.</p>
*
* @param context The context for this request
* @param include The forward to be performed
*/
- protected abstract void perform(ActionContext context,
- String include)
- throws Exception;
-
-
+ protected abstract void perform(ActionContext context, String include)
+ throws Exception;
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPopulateActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPopulateActionForm.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPopulateActionForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPopulateActionForm.java Fri Jan 20 16:19:02 2006
@@ -13,38 +13,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
-import java.util.Map;
-
import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ActionConfig;
+import java.util.Map;
/**
* <p>Populate the form bean (if any) for this request.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public abstract class AbstractPopulateActionForm extends ActionCommandBase {
-
-
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Populate the form bean (if any) for this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Is there a form bean for this request?
ActionForm actionForm = actionCtx.getActionForm();
@@ -62,52 +56,52 @@
handleCancel(actionCtx, actionConfig, actionForm);
return (false);
-
}
-
// ------------------------------------------------------- Protected Methods
/**
- * <p>Call the <code>reset()</code> method on the specified form bean.</p>
+ * <p>Call the <code>reset()</code> method on the specified form
+ * bean.</p>
*
- * @param context The context for this reqest
+ * @param context The context for this reqest
* @param actionConfig The actionConfig for this request
- * @param actionForm The form bean for this request
+ * @param actionForm The form bean for this request
*/
protected abstract void reset(ActionContext context,
ActionConfig actionConfig,
ActionForm actionForm);
-
/**
- * Populate the given <code>ActionForm</code> with request parameter values,
- * taking into account any prefix/suffix values configured on the given
- * <code>ActionConfig</code>.
+ * Populate the given <code>ActionForm</code> with request parameter
+ * values, taking into account any prefix/suffix values configured on the
+ * given <code>ActionConfig</code>.
*
* @param context
* @param actionConfig
* @param actionForm
* @throws Exception
*/
+
// original implementation casting context to WebContext is not safe
// when the input value is an ActionContext.
protected abstract void populate(ActionContext context,
ActionConfig actionConfig,
- ActionForm actionForm) throws Exception;
-
+ ActionForm actionForm)
+ throws Exception;
/**
- * <p>For a given request parameter name, trim off any prefix and/or suffix
- * which are defined in <code>actionConfig</code> and return what remains.
- * If either prefix or suffix is defined, then return null for
+ * <p>For a given request parameter name, trim off any prefix and/or
+ * suffix which are defined in <code>actionConfig</code> and return what
+ * remains. If either prefix or suffix is defined, then return null for
* <code>name</code> values which do not begin or end accordingly.</p>
- *
+ *
* @param actionConfig
* @param name
* @return
*/
- protected String trimParameterName(ActionConfig actionConfig, String name) {
+ protected String trimParameterName(ActionConfig actionConfig,
+ String name) {
String stripped = name;
String prefix = actionConfig.getPrefix();
String suffix = actionConfig.getSuffix();
@@ -116,24 +110,26 @@
if (!stripped.startsWith(prefix)) {
return null;
}
+
stripped = stripped.substring(prefix.length());
}
+
if (suffix != null) {
if (!stripped.endsWith(suffix)) {
return null;
}
- stripped =
- stripped.substring(0, stripped.length() - suffix.length());
+
+ stripped = stripped.substring(0, stripped.length()
+ - suffix.length());
}
return stripped;
-
}
/**
- * <p>Take into account whether the request includes
- * any defined value for the global "cancel" parameter.</p>
- *
+ * <p>Take into account whether the request includes any defined value for
+ * the global "cancel" parameter.</p>
+ *
* @param context
* @param actionConfig
* @param actionForm
@@ -141,19 +137,20 @@
* @see Globals.CANCEL_PROPERTY
* @see Globals.CANCEL_PROPERTY_X
*/
- protected void handleCancel(ActionContext context,
- ActionConfig actionConfig,
- ActionForm actionForm)
+ protected void handleCancel(ActionContext context,
+ ActionConfig actionConfig,
+ ActionForm actionForm)
throws Exception {
Map paramValues = context.getParameterMap();
// Set the cancellation attribute if appropriate
- /** @todo An issue was raised (but I don't think a Bugzilla ticket
- * created) about the security implications of using a well-known
- * cancel property which skips form validation, as you may not write
+
+ /** @todo An issue was raised (but I don't think a Bugzilla ticket
+ * created) about the security implications of using a well-known
+ * cancel property which skips form validation, as you may not write
* your actions to deal with the cancellation case. */
- if ((paramValues.get(Globals.CANCEL_PROPERTY) != null) ||
- (paramValues.get(Globals.CANCEL_PROPERTY_X) != null)) {
+ if ((paramValues.get(Globals.CANCEL_PROPERTY) != null)
+ || (paramValues.get(Globals.CANCEL_PROPERTY_X) != null)) {
context.setCancelled(Boolean.TRUE);
} else {
context.setCancelled(Boolean.FALSE);
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractRequestNoCache.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractRequestNoCache.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractRequestNoCache.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractRequestNoCache.java Fri Jan 20 16:19:02 2006
@@ -13,37 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ModuleConfig;
-
/**
- * <p>Check to see if the controller is configured to prevent caching,
- * and if so, request no cache flags to be set.</p>
+ * <p>Check to see if the controller is configured to prevent caching, and if
+ * so, request no cache flags to be set.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
+ * $
*/
-
public abstract class AbstractRequestNoCache extends ActionCommandBase {
-
-
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Check to see if the controller is configured to prevent caching,
- * and if so, request no cache flags to be set.</p>
+ * <p>Check to see if the controller is configured to prevent caching, and
+ * if so, request no cache flags to be set.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Retrieve the ModuleConfig instance
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
@@ -51,20 +44,16 @@
if (moduleConfig.getControllerConfig().getNocache()) {
requestNoCache(actionCtx);
}
- return (false);
+ return (false);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Request no cache flags are set.</p>
*
* @param context The <code>Context</code> for this request
*/
protected abstract void requestNoCache(ActionContext context);
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectAction.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectAction.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectAction.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectAction.java Fri Jan 20 16:19:02 2006
@@ -13,43 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ActionConfig;
import org.apache.struts.config.ModuleConfig;
-
/**
- * <p>Cache the <code>ActionConfig</code> instance for the
- * action to be used for processing this request.</p>
+ * <p>Cache the <code>ActionConfig</code> instance for the action to be used
+ * for processing this request.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-05 21:44:59 -0500 (Sat, 05 Nov 2005)
+ * $
*/
-
public abstract class AbstractSelectAction extends ActionCommandBase {
-
-
-
-
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Cache the <code>ActionConfig</code> instance for the
- * action to be used for processing this request.</p>
+ * <p>Cache the <code>ActionConfig</code> instance for the action to be
+ * used for processing this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
- * @exception IllegalArgumentException if no valid
- * action can be identified for this request
- *
* @return <code>false</code> so that processing continues
+ * @throws IllegalArgumentException if no valid action can be identified
+ * for this request
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Identify the matching path for this request
String path = getPath(actionCtx);
@@ -60,39 +50,37 @@
if (actionConfig == null) {
//:TODO Shouldn't this be the responsibility of ModuleConfig?
// Locate the mapping for unknown paths (if any)
- ActionConfig configs[] = moduleConfig.findActionConfigs();
+ ActionConfig[] configs = moduleConfig.findActionConfigs();
+
for (int i = 0; i < configs.length; i++) {
if (configs[i].getUnknown()) {
actionConfig = configs[i];
+
break;
}
}
-
}
if (actionConfig == null) {
throw new InvalidPathException(
- "No action config found for the specified url.", path);
+ "No action config found for the specified url.",
+ path);
}
+
actionCtx.setActionConfig(actionConfig);
- return (false);
+ return (false);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Return the path to be used to select the <code>ActionConfig</code>
* for this request.</p>
*
* @param context The <code>Context</code> for this request
- *
- * @exception IllegalArgumentException if no valid
- * action can be identified for this request
+ * @throws IllegalArgumentException if no valid action can be identified
+ * for this request
*/
protected abstract String getPath(ActionContext context);
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectForward.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectForward.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectForward.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectForward.java Fri Jan 20 16:19:02 2006
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.chain.contexts.ActionContext;
@@ -24,37 +22,32 @@
import org.apache.struts.config.ForwardConfig;
import org.apache.struts.config.ModuleConfig;
-
/**
* <p>Select and cache the <code>ActionForward</code> for this
* <code>ActionConfig</code> if specified.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
+ * $
*/
-
public abstract class AbstractSelectForward extends ActionCommandBase {
-
-
// ------------------------------------------------------ Instance Variables
private static final Log log =
- LogFactory.getLog(AbstractSelectForward.class);
-
+ LogFactory.getLog(AbstractSelectForward.class);
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Select and cache the <code>ActionForward</code> for this
* <code>ActionConfig</code> if specified.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Skip processing if the current request is not valid
Boolean valid = actionCtx.getFormValid();
+
if ((valid == null) || !valid.booleanValue()) {
return (false);
}
@@ -65,33 +58,31 @@
ForwardConfig forwardConfig = null;
String forward = actionConfig.getForward();
+
if (forward != null) {
forwardConfig = forward(actionCtx, moduleConfig, forward);
+
if (log.isDebugEnabled()) {
log.debug("Forwarding to " + forwardConfig);
}
+
actionCtx.setForwardConfig(forwardConfig);
}
- return (false);
+ return (false);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Create and return a <code>ForwardConfig</code> representing the
* specified module-relative destination.</p>
*
- * @param context The context for this request
+ * @param context The context for this request
* @param moduleConfig The <code>ModuleConfig</code> for this request
- * @param uri The module-relative URI to be the destination
+ * @param uri The module-relative URI to be the destination
*/
protected abstract ForwardConfig forward(ActionContext context,
ModuleConfig moduleConfig,
String uri);
-
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectInput.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectInput.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectInput.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectInput.java Fri Jan 20 16:19:02 2006
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.chain.contexts.ActionContext;
@@ -24,37 +22,32 @@
import org.apache.struts.config.ForwardConfig;
import org.apache.struts.config.ModuleConfig;
-
/**
* <p>Select and cache a <code>ForwardConfig</code> that returns us to the
* input page for the current action, if any.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
+ * $
*/
-
public abstract class AbstractSelectInput extends ActionCommandBase {
-
-
// ------------------------------------------------------ Instance Variables
- private static final Log log = LogFactory.getLog(AbstractSelectInput.class);
-
-
+ private static final Log log =
+ LogFactory.getLog(AbstractSelectInput.class);
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Select and cache a <code>ForwardConfig</code> for the input page
- * for the current request.</p>
+ * <p>Select and cache a <code>ForwardConfig</code> for the input page for
+ * the current request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Skip processing if the current request is valid
Boolean valid = actionCtx.getFormValid();
+
if ((valid != null) && valid.booleanValue()) {
return (false);
}
@@ -66,11 +59,14 @@
// Cache an ForwardConfig back to our input page
ForwardConfig forwardConfig = null;
String input = actionConfig.getInput();
+
if (moduleConfig.getControllerConfig().getInputForward()) {
if (log.isTraceEnabled()) {
log.trace("Finding ForwardConfig for '" + input + "'");
}
+
forwardConfig = actionConfig.findForwardConfig(input);
+
if (forwardConfig == null) {
forwardConfig = moduleConfig.findForwardConfig(input);
}
@@ -78,34 +74,30 @@
if (log.isTraceEnabled()) {
log.trace("Delegating to forward() for '" + input + "'");
}
+
forwardConfig = forward(actionCtx, moduleConfig, input);
}
+
if (log.isDebugEnabled()) {
log.debug("Forwarding back to " + forwardConfig);
}
+
actionCtx.setForwardConfig(forwardConfig);
- return (false);
+ return (false);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Create and return a <code>ForwardConfig</code> representing the
* specified module-relative destination.</p>
*
- * @param context The context for this request
+ * @param context The context for this request
* @param moduleConfig The <code>ModuleConfig</code> for this request
- * @param uri The module-relative URI to be the destination
+ * @param uri The module-relative URI to be the destination
*/
protected abstract ForwardConfig forward(ActionContext context,
ModuleConfig moduleConfig,
String uri);
-
-
}
-
-
-
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectLocale.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectLocale.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectLocale.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectLocale.java Fri Jan 20 16:19:02 2006
@@ -13,73 +13,67 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
-import java.util.Locale;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ModuleConfig;
+import java.util.Locale;
/**
* <p>Select the <code>Locale</code> to be used for this request.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public abstract class AbstractSelectLocale extends ActionCommandBase {
-
- private static final Log log =
+ private static final Log log =
LogFactory.getLog(AbstractSelectLocale.class);
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Select the <code>Locale</code> to be used for this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Are we configured to select Locale automatically?
log.trace("retrieve config...");
+
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
+
if (!moduleConfig.getControllerConfig().getLocale()) {
if (log.isDebugEnabled()) {
- log.debug("module is not configured for a specific locale; "
+ log.debug("module is not configured for a specific locale; "
+ "nothing to do");
}
+
return (false);
}
// Retrieve and cache appropriate Locale for this request
Locale locale = getLocale(actionCtx);
+
if (log.isDebugEnabled()) {
log.debug("set context locale to " + locale);
}
+
actionCtx.setLocale(locale);
return (false);
-
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Return the <code>Locale</code> to be used for this request.</p>
*
* @param context The <code>Context</code> for this request
*/
protected abstract Locale getLocale(ActionContext context);
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectModule.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectModule.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectModule.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSelectModule.java Fri Jan 20 16:19:02 2006
@@ -13,90 +13,83 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.struts.Globals;
import org.apache.struts.chain.Constants;
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.util.MessageResources;
-
/**
* <p>Cache the <code>ModuleConfig</code> and <code>MessageResources</code>
- * instances for the sub-application module to be used for processing
- * this request.</p>
+ * instances for the sub-application module to be used for processing this
+ * request.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public abstract class AbstractSelectModule extends ActionCommandBase {
-
-
// ------------------------------------------------------ Instance Variables
-
-
private String messageResourcesKey = Constants.MESSAGE_RESOURCES_KEY;
private String moduleConfigKey = Constants.MODULE_CONFIG_KEY;
-
-
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Cache the <code>ModuleConfig</code> and <code>MessageResources</code>
- * instances for the sub-application module to be used for processing
- * this request.</p>
+ * instances for the sub-application module to be used for processing this
+ * request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
- * @exception IllegalArgumentException if no valid
- * ModuleConfig or MessageResources can be identified for this request
- *
* @return <code>false</code> so that processing continues
+ * @throws IllegalArgumentException if no valid ModuleConfig or
+ * MessageResources can be identified for
+ * this request
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
String prefix = getPrefix(actionCtx);
// Cache the corresponding ModuleConfig and MessageResources instances
- ModuleConfig moduleConfig = (ModuleConfig)
- actionCtx.getApplicationScope().get(Globals.MODULE_KEY + prefix);
+ ModuleConfig moduleConfig =
+ (ModuleConfig) actionCtx.getApplicationScope()
+ .get(Globals.MODULE_KEY
+ + prefix);
+
if (moduleConfig == null) {
- throw new IllegalArgumentException("No module config for prefix '" +
- prefix + "'");
+ throw new IllegalArgumentException("No module config for prefix '"
+ + prefix + "'");
}
+
actionCtx.setModuleConfig(moduleConfig);
+
String key = Globals.MESSAGES_KEY + prefix;
- MessageResources messageResources = (MessageResources)
- actionCtx.getApplicationScope().get(key);
+ MessageResources messageResources =
+ (MessageResources) actionCtx.getApplicationScope()
+ .get(key);
+
if (messageResources == null) {
throw new IllegalArgumentException(
- "No message resources found in application scope under "
- + key);
+ "No message resources found in application scope under "
+ + key);
}
+
actionCtx.setMessageResources(messageResources);
return (false);
-
}
-
// ------------------------------------------------------- Protected Methods
-
/**
- * <p>Calculate and return the module prefix for the module to be
- * selected for this request.</p>
+ * <p>Calculate and return the module prefix for the module to be selected
+ * for this request.</p>
*
* @param context The <code>Context</code> for this request
- *
- * @exception IllegalArgumentException if no valid
- * ModuleConfig or MessageResources can be identified for this request
+ * @throws IllegalArgumentException if no valid ModuleConfig or
+ * MessageResources can be identified for
+ * this request
*/
protected abstract String getPrefix(ActionContext context);
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetContentType.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetContentType.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetContentType.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetContentType.java Fri Jan 20 16:19:02 2006
@@ -13,62 +13,52 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ModuleConfig;
-
/**
* <p>Check to see if the content type is set, and if so, set it for this
* response.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public abstract class AbstractSetContentType extends ActionCommandBase {
-
-
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Check to see if the content type is set, and if so, set it for this
* response.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Retrieve the ModuleConfig instance
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
// If the content type is configured, set it for the response
- String contentType =
+ String contentType =
moduleConfig.getControllerConfig().getContentType();
-
+
if (contentType != null) {
setContentType(actionCtx, contentType);
}
- return (false);
+ return (false);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Request no cache flags are set.</p>
*
- * @param context The <code>Context</code> for this request
+ * @param context The <code>Context</code> for this request
* @param contentType The content type for the response
*/
- protected abstract void setContentType(ActionContext context,
+ protected abstract void setContentType(ActionContext context,
String contentType);
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetOriginalURI.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetOriginalURI.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetOriginalURI.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractSetOriginalURI.java Fri Jan 20 16:19:02 2006
@@ -1,71 +1,56 @@
-/*
- * Copyright 2003,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.struts.chain.commands;
-
-
-import org.apache.struts.Globals;
-import org.apache.struts.chain.contexts.ActionContext;
-import org.apache.struts.config.ModuleConfig;
-
-
-/**
- * <p>Check to original uri is set, and if not, set it for this
- * request.</p>
- *
- * @version $Rev: 179995 $ $Date: 2005-06-04 07:58:46 -0700 (Sat, 04 Jun 2005) $
- */
-
-public abstract class AbstractSetOriginalURI extends ActionCommandBase {
-
-
- // ---------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Check to original uri is set, and if not, set it for this
- * request.</p>
- *
- * @param actionCtx The <code>Context</code> for the current request
- *
- * @return <code>false</code> so that processing continues
- */
- public boolean execute(ActionContext actionCtx) throws Exception {
-
- // Set the original uri if not already set
- if (!actionCtx.getRequestScope()
- .containsKey(Globals.ORIGINAL_URI_KEY)) {
-
- setOriginalURI(actionCtx);
- }
-
- return (false);
-
- }
-
-
- // ------------------------------------------------------- Protected Methods
-
-
- /**
- * <p>Set the original uri.</p>
- *
- * @param context The <code>Context</code> for this request
- */
- protected abstract void setOriginalURI(ActionContext context);
-
-
-}
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts.chain.commands;
+
+import org.apache.struts.Globals;
+import org.apache.struts.chain.contexts.ActionContext;
+
+/**
+ * <p>Check to original uri is set, and if not, set it for this request.</p>
+ *
+ * @version $Rev: 179995 $ $Date: 2005-06-04 07:58:46 -0700 (Sat, 04 Jun 2005)
+ * $
+ */
+public abstract class AbstractSetOriginalURI extends ActionCommandBase {
+ // ---------------------------------------------------------- Public Methods
+
+ /**
+ * <p>Check to original uri is set, and if not, set it for this
+ * request.</p>
+ *
+ * @param actionCtx The <code>Context</code> for the current request
+ * @return <code>false</code> so that processing continues
+ */
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
+ // Set the original uri if not already set
+ if (!actionCtx.getRequestScope()
+ .containsKey(Globals.ORIGINAL_URI_KEY)) {
+ setOriginalURI(actionCtx);
+ }
+
+ return (false);
+ }
+
+ // ------------------------------------------------------- Protected Methods
+
+ /**
+ * <p>Set the original uri.</p>
+ *
+ * @param context The <code>Context</code> for this request
+ */
+ protected abstract void setOriginalURI(ActionContext context);
+}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractValidateActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractValidateActionForm.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractValidateActionForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractValidateActionForm.java Fri Jan 20 16:19:02 2006
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionErrors;
@@ -24,55 +22,56 @@
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.config.ActionConfig;
-
/**
* <p>Validate the properties of the form bean for this request. If there are
- * any validation errors, execute the specified command; otherwise,
- * proceed normally.</p>
+ * any validation errors, execute the specified command; otherwise, proceed
+ * normally.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
+ * $
*/
-
public abstract class AbstractValidateActionForm extends ActionCommandBase {
-
-
// ------------------------------------------------------ Instance Variables
private static final Log log =
- LogFactory.getLog(AbstractValidateActionForm.class);
+ LogFactory.getLog(AbstractValidateActionForm.class);
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Validate the properties of the form bean for this request. If
- * there are any validation errors, execute the child commands in our
- * chain; otherwise, proceed normally.</p>
+ * <p>Validate the properties of the form bean for this request. If there
+ * are any validation errors, execute the child commands in our chain;
+ * otherwise, proceed normally.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues, if there are
- * no validation errors; otherwise <code>true</code>
+ * no validation errors; otherwise <code>true</code>
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Is there a form bean for this request?
ActionForm actionForm = actionCtx.getActionForm();
+
if (actionForm == null) {
actionCtx.setFormValid(Boolean.TRUE);
+
return (false);
}
// Was this request cancelled?
Boolean cancel = actionCtx.getCancelled();
+
if ((cancel != null) && cancel.booleanValue()) {
actionCtx.setFormValid(Boolean.TRUE);
+
return (false);
}
// Is validation disabled on this request?
ActionConfig actionConfig = actionCtx.getActionConfig();
+
if (!actionConfig.getValidate()) {
actionCtx.setFormValid(Boolean.TRUE);
+
return (false);
}
@@ -82,6 +81,7 @@
// If there were no errors, proceed normally
if ((errors == null) || (errors.isEmpty())) {
actionCtx.setFormValid(Boolean.TRUE);
+
return (false);
}
@@ -90,25 +90,21 @@
* been errors, or that other errors might be coming? */
actionCtx.saveErrors(errors);
actionCtx.setFormValid(Boolean.FALSE);
- return (false);
+ return (false);
}
-
// ------------------------------------------------------- Protected Methods
-
/**
* <p>Call the <code>validate()</code> method of the specified form bean,
* and return the resulting <code>ActionErrors</code> object.</p>
*
- * @param context The context for this request
+ * @param context The context for this request
* @param actionConfig The <code>ActionConfig</code> for this request
- * @param actionForm The form bean for this request
+ * @param actionForm The form bean for this request
*/
protected abstract ActionErrors validate(ActionContext context,
ActionConfig actionConfig,
ActionForm actionForm);
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommand.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommand.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommand.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommand.java Fri Jan 20 16:19:02 2006
@@ -1,32 +1,30 @@
-/*
- * $Id$
- *
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.struts.chain.commands;
-
-import org.apache.commons.chain.Command;
-import org.apache.struts.chain.contexts.ActionContext;
-
-/**
- * <p>Marks a commons-chain <code>Command</code> which expects to operate
- * upon a Struts <code>ActionContext</code>.</p>
- */
-public interface ActionCommand extends Command {
- boolean execute(ActionContext actionContext) throws Exception;
-}
-
-
+/*
+ * $Id$
+ *
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts.chain.commands;
+
+import org.apache.commons.chain.Command;
+import org.apache.struts.chain.contexts.ActionContext;
+
+/**
+ * <p>Marks a commons-chain <code>Command</code> which expects to operate upon
+ * a Struts <code>ActionContext</code>.</p>
+ */
+public interface ActionCommand extends Command {
+ boolean execute(ActionContext actionContext)
+ throws Exception;
+}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommandBase.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommandBase.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommandBase.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/ActionCommandBase.java Fri Jan 20 16:19:02 2006
@@ -1,44 +1,40 @@
-/*
- * $Id$
- *
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.struts.chain.commands;
-
-import org.apache.commons.chain.Context;
-import org.apache.struts.chain.contexts.ActionContext;
-
-/**
- * <p>Simple abstract class which avoids frequent casting to
- * <code>ActionContext</code> in commands explicitly intended
- * for use with that class.</code>.</p>
- */
-public abstract class ActionCommandBase implements ActionCommand {
-
- public abstract boolean execute(ActionContext actionContext)
- throws Exception;
-
- /**
- * <p>Simply cast the <code>Context</code> to <code>ActionContext</code>
- * and call <code>execute(ActionContext)</code>.</p>
- */
- public boolean execute(Context context) throws Exception {
- return execute((ActionContext) context);
- }
-
-}
-
-
+/*
+ * $Id$
+ *
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts.chain.commands;
+
+import org.apache.commons.chain.Context;
+import org.apache.struts.chain.contexts.ActionContext;
+
+/**
+ * <p>Simple abstract class which avoids frequent casting to
+ * <code>ActionContext</code> in commands explicitly intended for use with
+ * that class.</code>.</p>
+ */
+public abstract class ActionCommandBase implements ActionCommand {
+ public abstract boolean execute(ActionContext actionContext)
+ throws Exception;
+
+ /**
+ * <p>Simply cast the <code>Context</code> to <code>ActionContext</code>
+ * and call <code>execute(ActionContext)</code>.</p>
+ */
+ public boolean execute(Context context)
+ throws Exception {
+ return execute((ActionContext) context);
+ }
+}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/CreateActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/CreateActionForm.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/CreateActionForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/CreateActionForm.java Fri Jan 20 16:19:02 2006
@@ -13,12 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
-import java.util.Map;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
@@ -27,6 +23,7 @@
import org.apache.struts.config.ActionConfig;
import org.apache.struts.config.FormBeanConfig;
+import java.util.Map;
/**
* <p>Create (if necessary) and cache a form bean for this request.</p>
@@ -34,31 +31,26 @@
* @version $Id$
*/
public class CreateActionForm extends ActionCommandBase {
-
-
// ------------------------------------------------------ Instance Variables
-
-
- private static final Log log =
- LogFactory.getLog(CreateActionForm.class);
+ private static final Log log = LogFactory.getLog(CreateActionForm.class);
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Create (if necessary) and cache a form bean for this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
-
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
// Is there a form bean associated with this ActionConfig?
ActionConfig actionConfig = actionCtx.getActionConfig();
String name = actionConfig.getName();
+
if (name == null) {
actionCtx.setActionForm(null);
+
return (false);
}
@@ -67,19 +59,23 @@
}
// Look up the corresponding FormBeanConfig (if any)
- FormBeanConfig formBeanConfig =
- actionConfig.getModuleConfig().findFormBeanConfig(name);
+ FormBeanConfig formBeanConfig = actionConfig.getModuleConfig()
+ .findFormBeanConfig(name);
+
if (formBeanConfig == null) {
log.warn("No FormBeanConfig found in module "
- + actionConfig.getModuleConfig().getPrefix()
- + " under name " + name);
+ + actionConfig.getModuleConfig().getPrefix()
+ + " under name "
+ + name);
actionCtx.setActionForm(null);
+
return (false);
}
Map scope = actionCtx.getScope(actionConfig.getScope());
ActionForm instance = null;
+
instance = (ActionForm) scope.get(actionConfig.getAttribute());
// Can we recycle the existing instance (if any)?
@@ -87,13 +83,14 @@
instance = formBeanConfig.createActionForm(actionCtx);
}
- // TODO Remove this when ActionForm no longer directly depends on
+ // TODO Remove this when ActionForm no longer directly depends on
// ActionServlet
if (actionCtx instanceof ServletActionContext) {
// The servlet property of ActionForm is transient, so
// ActionForms which are restored from a serialized state
// need to have their servlet restored.
ServletActionContext sac = (ServletActionContext) actionCtx;
+
instance.setServlet(sac.getActionServlet());
}
@@ -102,7 +99,5 @@
scope.put(actionConfig.getAttribute(), instance);
return (false);
-
}
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/ExceptionCatcher.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/ExceptionCatcher.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/ExceptionCatcher.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/ExceptionCatcher.java Fri Jan 20 16:19:02 2006
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.chain.commands;
-
import org.apache.commons.chain.Catalog;
import org.apache.commons.chain.CatalogFactory;
import org.apache.commons.chain.Command;
@@ -26,42 +24,32 @@
import org.apache.commons.logging.LogFactory;
import org.apache.struts.chain.contexts.ActionContext;
-
/**
- * <p>Intercept any exception thrown by a subsequent <code>Command</code>
- * in this processing chain, and fire the configured exception handler chain
- * after storing the exception that has occurred into the <code>Context</code>.
- * </p>
+ * <p>Intercept any exception thrown by a subsequent <code>Command</code> in
+ * this processing chain, and fire the configured exception handler chain
+ * after storing the exception that has occurred into the
+ * <code>Context</code>. </p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public class ExceptionCatcher extends ActionCommandBase implements Filter {
-
+ private static final Log log = LogFactory.getLog(ExceptionCatcher.class);
// ------------------------------------------------------ Instance Variables
-
-
private String catalogName = null;
private String exceptionCommand = null;
- private static final Log log = LogFactory.getLog(ExceptionCatcher.class);
-
-
// -------------------------------------------------------------- Properties
-
/**
* <p>Return the name of the <code>Catalog</code> in which to perform
* lookups, or <code>null</code> for the default <code>Catalog</code>.</p>
*/
public String getCatalogName() {
-
return (this.catalogName);
-
}
-
/**
* <p>Set the name of the <code>Catalog</code> in which to perform
* lookups, or <code>null</code> for the default <code>Catalog</code>.</p>
@@ -69,65 +57,53 @@
* @param catalogName The new catalog name or <code>null</code>
*/
public void setCatalogName(String catalogName) {
-
this.catalogName = catalogName;
-
}
-
/**
- * <p>Return the name of the command to be executed
- * if an exception occurs.</p>
+ * <p>Return the name of the command to be executed if an exception
+ * occurs.</p>
*/
public String getExceptionCommand() {
-
return (this.exceptionCommand);
-
}
-
/**
- * <p>Set the name of the command to be executed
- * if an exception occurs.</p>
+ * <p>Set the name of the command to be executed if an exception
+ * occurs.</p>
*
* @param exceptionCommand The name of the chain to be executed
*/
public void setExceptionCommand(String exceptionCommand) {
-
this.exceptionCommand = exceptionCommand;
-
}
-
-
// ---------------------------------------------------------- Public Methods
-
/**
- * <p>Clear any existing stored exception and pass the <code>context</code>
- * on to the remainder of the current chain.</p>
+ * <p>Clear any existing stored exception and pass the
+ * <code>context</code> on to the remainder of the current chain.</p>
*
* @param actionCtx The <code>Context</code> for the current request
- *
* @return <code>false</code> so that processing continues
*/
- public boolean execute(ActionContext actionCtx) throws Exception {
+ public boolean execute(ActionContext actionCtx)
+ throws Exception {
actionCtx.setException(null);
- return (false);
+ return (false);
}
-
/**
* <p>If an exception was thrown by a subsequent <code>Command</code>,
- * pass it on to the specified exception handling chain. Otherwise,
- * do nothing.</p>
+ * pass it on to the specified exception handling chain. Otherwise, do
+ * nothing.</p>
*
- * @param context The {@link Context} to be processed by this
- * {@link Filter}
- * @param exception The <code>Exception</code> (if any) that was thrown
- * by the last {@link Command} that was executed; otherwise
- * <code>null</code>
+ * @param context The {@link Context} to be processed by this {@link
+ * Filter}
+ * @param exception The <code>Exception</code> (if any) that was thrown by
+ * the last {@link Command} that was executed; otherwise
+ * <code>null</code>
*/
public boolean postprocess(Context context, Exception exception) {
// Do nothing if there was no exception thrown
@@ -139,60 +115,70 @@
if (log.isDebugEnabled()) {
log.debug("Attempting to handle a thrown exception");
}
+
ActionContext actionCtx = (ActionContext) context;
+
actionCtx.setException(exception);
// Execute the specified command
try {
Command command = lookupExceptionCommand();
+
if (command == null) {
- log.error("Cannot find exceptionCommand '" +
- exceptionCommand + "'");
- throw new IllegalStateException
- ("Cannot find exceptionCommand '" +
- exceptionCommand + "'");
+ log.error("Cannot find exceptionCommand '" + exceptionCommand
+ + "'");
+ throw new IllegalStateException(
+ "Cannot find exceptionCommand '" + exceptionCommand
+ + "'");
}
+
if (log.isTraceEnabled()) {
log.trace("Calling exceptionCommand '" + exceptionCommand
- + "'");
+ + "'");
}
+
command.execute(context);
- } catch (Exception e) {
- log.warn("Exception from exceptionCommand '" +
- exceptionCommand + "'", e);
+ }
+ catch (Exception e) {
+ log.warn("Exception from exceptionCommand '" + exceptionCommand
+ + "'", e);
throw new IllegalStateException("Exception chain threw exception");
}
- return (true);
+ return (true);
}
- protected Command lookupExceptionCommand()
+ protected Command lookupExceptionCommand()
throws IllegalArgumentException, IllegalStateException {
String catalogName = getCatalogName();
Catalog catalog = null;
+
if (catalogName == null) {
catalog = CatalogFactory.getInstance().getCatalog();
+
if (catalog == null) {
log.error("Cannot find default catalog");
- throw new IllegalArgumentException
- ("Cannot find default catalog");
+ throw new IllegalArgumentException(
+ "Cannot find default catalog");
}
} else {
catalog = CatalogFactory.getInstance().getCatalog(catalogName);
+
if (catalog == null) {
log.error("Cannot find catalog '" + catalogName + "'");
- throw new IllegalArgumentException
- ("Cannot find catalog '" + catalogName + "'");
+ throw new IllegalArgumentException("Cannot find catalog '"
+ + catalogName + "'");
}
}
+
String exceptionCommand = getExceptionCommand();
+
if (exceptionCommand == null) {
log.error("No exceptionCommand property specified");
- throw new IllegalStateException
- ("No exceptionCommand property specfied");
+ throw new IllegalStateException(
+ "No exceptionCommand property specfied");
}
- return catalog.getCommand(exceptionCommand);
+ return catalog.getCommand(exceptionCommand);
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org