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 [2/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/Globals.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/Globals.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/Globals.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/Globals.java Fri Jan 20 16:19:02 2006
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts;
import java.io.Serializable;
@@ -23,14 +22,12 @@
/**
* Global manifest constants for the entire Struts Framework.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-06-18 20:27:26 -0400 (Sat, 18 Jun 2005)
+ * $
*/
public class Globals implements Serializable {
-
-
// ----------------------------------------------------- Manifest Constants
-
/**
* The context attributes key under which our <code>ActionServlet</code>
* instance will be stored.
@@ -38,7 +35,7 @@
* @since Struts 1.1
*/
public static final String ACTION_SERVLET_KEY =
- "org.apache.struts.action.ACTION_SERVLET";
+ "org.apache.struts.action.ACTION_SERVLET";
/**
* The request attributes key under which a boolean <code>true</code>
@@ -46,48 +43,47 @@
*
* @since Struts 1.1
*/
- public static final String CANCEL_KEY =
- "org.apache.struts.action.CANCEL";
+ public static final String CANCEL_KEY = "org.apache.struts.action.CANCEL";
/**
* <p>The base of the context attributes key under which our
- * <code>ModuleConfig</code> data structure will be stored. This
- * will be suffixed with the actual module prefix (including the
- * leading "/" character) to form the actual attributes key.</p>
+ * <code>ModuleConfig</code> data structure will be stored. This will be
+ * suffixed with the actual module prefix (including the leading "/"
+ * character) to form the actual attributes key.</p>
*
* <p>For each request processed by the controller servlet, the
- * <code>ModuleConfig</code> object for the module selected by
- * the request URI currently being processed will also be exposed under
- * this key as a request attribute.</p>
+ * <code>ModuleConfig</code> object for the module selected by the request
+ * URI currently being processed will also be exposed under this key as a
+ * request attribute.</p>
*
* @since Struts 1.1
*/
- public static final String MODULE_KEY =
- "org.apache.struts.action.MODULE";
+ public static final String MODULE_KEY = "org.apache.struts.action.MODULE";
/**
* The ServletContext attribute under which we store the module prefixes
* String[].
+ *
* @since Struts 1.2
*/
public static final String MODULE_PREFIXES_KEY =
- "org.apache.struts.globals.MODULE_PREFIXES";
+ "org.apache.struts.globals.MODULE_PREFIXES";
- /**
- * The request attribute under which we store the original URI of the
+ /**
+ * The request attribute under which we store the original URI of the
* request.
+ *
* @since Struts 1.3
*/
public static final String ORIGINAL_URI_KEY =
- "org.apache.struts.globals.ORIGINAL_URI_KEY";
+ "org.apache.struts.globals.ORIGINAL_URI_KEY";
/**
* The request attributes key under which your action should store an
- * <code>org.apache.struts.action.ActionErrors</code> object, if you
- * are using the corresponding custom tag library elements.
+ * <code>org.apache.struts.action.ActionErrors</code> object, if you are
+ * using the corresponding custom tag library elements.
*/
- public static final String ERROR_KEY =
- "org.apache.struts.action.ERROR";
+ public static final String ERROR_KEY = "org.apache.struts.action.ERROR";
/**
* The request attributes key under which Struts custom tags might store a
@@ -96,130 +92,120 @@
* detailed information about what really went wrong.
*/
public static final String EXCEPTION_KEY =
- "org.apache.struts.action.EXCEPTION";
+ "org.apache.struts.action.EXCEPTION";
/**
* The session attributes key under which the user's selected
- * <code>java.util.Locale</code> is stored, if any. If no such
- * attribute is found, the system default locale
- * will be used when retrieving internationalized messages. If used, this
- * attribute is typically set during user login processing.
- */
- public static final String LOCALE_KEY =
- "org.apache.struts.action.LOCALE";
+ * <code>java.util.Locale</code> is stored, if any. If no such attribute
+ * is found, the system default locale will be used when retrieving
+ * internationalized messages. If used, this attribute is typically set
+ * during user login processing.
+ */
+ public static final String LOCALE_KEY = "org.apache.struts.action.LOCALE";
/**
- * The request attributes key under which our
- * <code>org.apache.struts.ActionMapping</code> instance
- * is passed.
+ * The request attributes key under which our <code>org.apache.struts.ActionMapping</code>
+ * instance is passed.
*/
public static final String MAPPING_KEY =
- "org.apache.struts.action.mapping.instance";
+ "org.apache.struts.action.mapping.instance";
/**
* The request attributes key under which your action should store an
- * <code>org.apache.struts.action.ActionMessages</code> object, if you
- * are using the corresponding custom tag library elements.
+ * <code>org.apache.struts.action.ActionMessages</code> object, if you are
+ * using the corresponding custom tag library elements.
*
* @since Struts 1.1
*/
public static final String MESSAGE_KEY =
- "org.apache.struts.action.ACTION_MESSAGE";
-
+ "org.apache.struts.action.ACTION_MESSAGE";
/**
- * <p>The base of the context attributes key under which our
- * module <code>MessageResources</code> will be stored. This
- * will be suffixed with the actual module prefix (including the
- * leading "/" character) to form the actual resources key.</p>
+ * <p>The base of the context attributes key under which our module
+ * <code>MessageResources</code> will be stored. This will be suffixed
+ * with the actual module prefix (including the leading "/" character) to
+ * form the actual resources key.</p>
*
* <p>For each request processed by the controller servlet, the
- * <code>MessageResources</code> object for the module selected by
- * the request URI currently being processed will also be exposed under
- * this key as a request attribute.</p>
+ * <code>MessageResources</code> object for the module selected by the
+ * request URI currently being processed will also be exposed under this
+ * key as a request attribute.</p>
*/
public static final String MESSAGES_KEY =
- "org.apache.struts.action.MESSAGE";
-
+ "org.apache.struts.action.MESSAGE";
/**
* The request attributes key under which our multipart class is stored.
*/
public static final String MULTIPART_KEY =
- "org.apache.struts.action.mapping.multipartclass";
-
+ "org.apache.struts.action.mapping.multipartclass";
/**
* <p>The base of the context attributes key under which an array of
- * <code>PlugIn</code> instances will be stored. This
- * will be suffixed with the actual module prefix (including the
- * leading "/" character) to form the actual attributes key.</p>
+ * <code>PlugIn</code> instances will be stored. This will be suffixed
+ * with the actual module prefix (including the leading "/" character) to
+ * form the actual attributes key.</p>
+ *
* @since Struts 1.1
*/
public static final String PLUG_INS_KEY =
- "org.apache.struts.action.PLUG_INS";
-
+ "org.apache.struts.action.PLUG_INS";
/**
* <p>The base of the context attributes key under which our
- * <code>RequestProcessor</code> instance will be stored. This
- * will be suffixed with the actual module prefix (including the
- * leading "/" character) to form the actual attributes key.</p>
+ * <code>RequestProcessor</code> instance will be stored. This will be
+ * suffixed with the actual module prefix (including the leading "/"
+ * character) to form the actual attributes key.</p>
+ *
* @since Struts 1.1
*/
public static final String REQUEST_PROCESSOR_KEY =
- "org.apache.struts.action.REQUEST_PROCESSOR";
-
+ "org.apache.struts.action.REQUEST_PROCESSOR";
/**
- * The context attributes key under which we store the mapping defined
- * for our controller serlet, which will be either a path-mapped pattern
+ * The context attributes key under which we store the mapping defined for
+ * our controller serlet, which will be either a path-mapped pattern
* (<code>/action/*</code>) or an extension mapped pattern
* (<code>*.do</code>).
*/
public static final String SERVLET_KEY =
- "org.apache.struts.action.SERVLET_MAPPING";
-
+ "org.apache.struts.action.SERVLET_MAPPING";
/**
- * The session attributes key under which our transaction token is
- * stored, if it is used.
+ * The session attributes key under which our transaction token is stored,
+ * if it is used.
*/
public static final String TRANSACTION_TOKEN_KEY =
- "org.apache.struts.action.TOKEN";
+ "org.apache.struts.action.TOKEN";
/**
- * The page attributes key under which xhtml status is stored. This may be
- * "true" or "false". When set to true, the html tags output xhtml.
+ * The page attributes key under which xhtml status is stored. This may
+ * be "true" or "false". When set to true, the html tags output xhtml.
+ *
* @since Struts 1.1
*/
- public static final String XHTML_KEY =
- "org.apache.struts.globals.XHTML";
+ public static final String XHTML_KEY = "org.apache.struts.globals.XHTML";
/**
* The name of the taglib package.
*/
- public static final String TaglibPackage = "org.apache.struts.taglib.html";
-
-
+ public static final String TaglibPackage =
+ "org.apache.struts.taglib.html";
/**
* The property under which a Cancel button press is reported.
*/
public static final String CANCEL_PROPERTY = TaglibPackage + ".CANCEL";
-
/**
* The property under which a Cancel button press is reported, if the
* Cancel button is rendered as an image.
*/
- public static final String CANCEL_PROPERTY_X = TaglibPackage + ".CANCEL.x";
-
+ public static final String CANCEL_PROPERTY_X =
+ TaglibPackage + ".CANCEL.x";
/**
* The property under which a transaction token is reported.
*/
public static final String TOKEN_KEY = TaglibPackage + ".TOKEN";
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/action/Action.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/Action.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/Action.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/Action.java Fri Jan 20 16:19:02 2006
@@ -15,10 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.action;
-import java.util.Locale;
+import org.apache.struts.Globals;
+import org.apache.struts.config.ModuleConfig;
+import org.apache.struts.util.MessageResources;
+import org.apache.struts.util.ModuleUtils;
+import org.apache.struts.util.RequestUtils;
+import org.apache.struts.util.TokenProcessor;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
@@ -26,13 +30,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-
-import org.apache.struts.Globals;
-import org.apache.struts.config.ModuleConfig;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.util.ModuleUtils;
-import org.apache.struts.util.RequestUtils;
-import org.apache.struts.util.TokenProcessor;
+import java.util.Locale;
/**
* <p>An <strong>Action</strong> is an adapter between the contents of an
@@ -42,65 +40,54 @@
* necessary), and call the <code>execute</code> method.</p>
*
* <p>Actions must be programmed in a thread-safe manner, because the
- * controller will share the same instance for multiple simultaneous
- * requests. This means you should design with the following items in mind:
- * </p>
- * <ul>
+ * controller will share the same instance for multiple simultaneous requests.
+ * This means you should design with the following items in mind: </p> <ul>
* <li>Instance and static variables MUST NOT be used to store information
- * related to the state of a particular request. They MAY be used to
- * share global resources across requests for the same action.</li>
- * <li>Access to other resources (JavaBeans, session variables, etc.) MUST
- * be synchronized if those resources require protection. (Generally,
- * however, resource classes should be designed to provide their own
- * protection where necessary.</li>
- * </ul>
+ * related to the state of a particular request. They MAY be used to share
+ * global resources across requests for the same action.</li> <li>Access to
+ * other resources (JavaBeans, session variables, etc.) MUST be synchronized
+ * if those resources require protection. (Generally, however, resource
+ * classes should be designed to provide their own protection where
+ * necessary.</li> </ul>
*
* <p>When an <code>Action</code> instance is first created, the controller
- * will call <code>setServlet</code> with a non-null argument to
- * identify the servlet instance to which this Action is attached.
- * When the servlet is to be shut down (or restarted), the
- * <code>setServlet</code> method will be called with a <code>null</code>
- * argument, which can be used to clean up any allocated resources in use
- * by this Action.</p>
+ * will call <code>setServlet</code> with a non-null argument to identify the
+ * servlet instance to which this Action is attached. When the servlet is to
+ * be shut down (or restarted), the <code>setServlet</code> method will be
+ * called with a <code>null</code> argument, which can be used to clean up any
+ * allocated resources in use by this Action.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-26 21:58:39 -0400 (Fri, 26 Aug 2005)
+ * $
*/
public class Action {
-
/**
* <p>An instance of <code>TokenProcessor</code> to use for token
* functionality.</p>
*/
private static TokenProcessor token = TokenProcessor.getInstance();
+
// :TODO: We can make this variable protected and remove Action's token
// methods or leave it private and allow the token methods to delegate
// their calls.
-
-
// ----------------------------------------------------- Instance Variables
-
/**
* <p>The servlet to which we are attached.</p>
*/
protected transient ActionServlet servlet = null;
-
// ------------------------------------------------------------- Properties
-
/**
* <p>Return the servlet instance to which we are attached.</p>
*
* @return The servlet instance to which we are attached.
*/
public ActionServlet getServlet() {
-
return (this.servlet);
-
}
-
/**
* <p>Set the servlet instance to which we are attached (if
* <code>servlet</code> is non-null), or release any allocated resources
@@ -109,110 +96,86 @@
* @param servlet The new controller servlet, if any
*/
public void setServlet(ActionServlet servlet) {
-
this.servlet = servlet;
- // :FIXME: Is this suppose to release resources?
-
+ // :FIXME: Is this suppose to release resources?
}
-
// --------------------------------------------------------- Public Methods
-
/**
- * <p>Process the specified non-HTTP request, and create the
- * corresponding non-HTTP response (or forward to another web
- * component that will create it), with provision for handling
- * exceptions thrown by the business logic.
- * Return an {@link ActionForward} instance describing where and how
- * control should be forwarded, or <code>null</code> if the response has
- * already been completed.</p>
- *
- * <p>The default implementation attempts to forward to the HTTP
- * version of this method.</p>
- *
- * @param mapping The ActionMapping used to select this instance
- * @param form The optional ActionForm bean for this request (if any)
- * @param request The non-HTTP request we are processing
+ * <p>Process the specified non-HTTP request, and create the corresponding
+ * non-HTTP response (or forward to another web component that will create
+ * it), with provision for handling exceptions thrown by the business
+ * logic. Return an {@link ActionForward} instance describing where and
+ * how control should be forwarded, or <code>null</code> if the response
+ * has already been completed.</p>
+ *
+ * <p>The default implementation attempts to forward to the HTTP version
+ * of this method.</p>
+ *
+ * @param mapping The ActionMapping used to select this instance
+ * @param form The optional ActionForm bean for this request (if any)
+ * @param request The non-HTTP request we are processing
* @param response The non-HTTP response we are creating
* @return The forward to which control should be transferred, or
* <code>null</code> if the response has been completed.
- *
- * @exception Exception if the application business logic throws
- * an exception.
+ * @throws Exception if the application business logic throws an
+ * exception.
* @since Struts 1.1
*/
- public ActionForward execute(
- ActionMapping mapping,
- ActionForm form,
- ServletRequest request,
- ServletResponse response)
- throws Exception {
-
+ public ActionForward execute(ActionMapping mapping, ActionForm form,
+ ServletRequest request,
+ ServletResponse response)
+ throws Exception {
try {
- return execute(
- mapping,
- form,
- (HttpServletRequest) request,
- (HttpServletResponse) response);
-
- } catch (ClassCastException e) {
+ return execute(mapping, form, (HttpServletRequest) request,
+ (HttpServletResponse) response);
+ }
+ catch (ClassCastException e) {
return null;
}
-
}
-
/**
- * <p>Process the specified HTTP request, and create the corresponding HTTP
- * response (or forward to another web component that will create it),
- * with provision for handling exceptions thrown by the business logic.
- * Return an {@link ActionForward} instance describing where and how
- * control should be forwarded, or <code>null</code> if the response
+ * <p>Process the specified HTTP request, and create the corresponding
+ * HTTP response (or forward to another web component that will create
+ * it), with provision for handling exceptions thrown by the business
+ * logic. Return an {@link ActionForward} instance describing where and
+ * how control should be forwarded, or <code>null</code> if the response
* has already been completed.</p>
*
- * @param mapping The ActionMapping used to select this instance
- * @param form The optional ActionForm bean for this request (if any)
- * @param request The HTTP request we are processing
+ * @param mapping The ActionMapping used to select this instance
+ * @param form 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
* @return The forward to which control should be transferred, or
* <code>null</code> if the response has been completed.
- *
- * @exception Exception if the application business logic throws
- * an exception
+ * @throws Exception if the application business logic throws an
+ * exception
* @since Struts 1.1
*/
- public ActionForward execute(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
+ public ActionForward execute(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
return null;
-
}
-
// ---------------------------------------------------- Protected Methods
-
/**
- * Adds the specified messages keys into the appropriate request
- * attribute for use by the <html:messages> tag (if
- * messages="true" is set), if any messages are required.
- * Initialize the attribute if it has not already been.
- * Otherwise, ensure that the request attribute is not set.
+ * Adds the specified messages keys into the appropriate request attribute
+ * for use by the <html:messages> tag (if messages="true" is set),
+ * if any messages are required. Initialize the attribute if it has not
+ * already been. Otherwise, ensure that the request attribute is not set.
*
- * @param request The servlet request we are processing
- * @param messages Messages object
+ * @param request The servlet request we are processing
+ * @param messages Messages object
* @since Struts 1.2.1
*/
- protected void addMessages(
- HttpServletRequest request,
- ActionMessages messages) {
-
+ protected void addMessages(HttpServletRequest request,
+ ActionMessages messages) {
if (messages == null) {
// bad programmer! *slap*
return;
@@ -221,15 +184,18 @@
// get any existing messages from the request, or make a new one
ActionMessages requestMessages =
(ActionMessages) request.getAttribute(Globals.MESSAGE_KEY);
+
if (requestMessages == null) {
requestMessages = new ActionMessages();
}
+
// add incoming messages
requestMessages.add(messages);
// if still empty, just wipe it out from the request
if (requestMessages.isEmpty()) {
request.removeAttribute(Globals.MESSAGE_KEY);
+
return;
}
@@ -237,21 +203,18 @@
request.setAttribute(Globals.MESSAGE_KEY, requestMessages);
}
-
/**
* Adds the specified errors keys into the appropriate request attribute
* for use by the <html:errors> tag, if any messages are required.
* Initialize the attribute if it has not already been. Otherwise, ensure
* that the request attribute is not set.
*
- * @param request The servlet request we are processing
+ * @param request The servlet request we are processing
* @param errors Errors object
* @since Struts 1.2.1
*/
- protected void addErrors(
- HttpServletRequest request,
- ActionMessages errors) {
-
+ protected void addErrors(HttpServletRequest request,
+ ActionMessages errors) {
if (errors == null) {
// bad programmer! *slap*
return;
@@ -260,15 +223,18 @@
// get any existing errors from the request, or make a new one
ActionMessages requestErrors =
(ActionMessages) request.getAttribute(Globals.ERROR_KEY);
+
if (requestErrors == null) {
requestErrors = new ActionMessages();
}
+
// add incoming errors
requestErrors.add(errors);
// if still empty, just wipe it out from the request
if (requestErrors.isEmpty()) {
request.removeAttribute(Globals.ERROR_KEY);
+
return;
}
@@ -276,7 +242,6 @@
request.setAttribute(Globals.ERROR_KEY, requestErrors);
}
-
/**
* <p>Generate a new transaction token, to be used for enforcing a single
* request for a particular transaction.</p>
@@ -288,29 +253,28 @@
return token.generateToken(request);
}
-
/**
- * Retrieves any existing errors placed in the request by previous actions.
- * This method could be called instead of creating a
- * <code>new ActionMessages()</code> at the beginning of an
- * <code>Action</code>. This will prevent saveErrors() from wiping out any
- * existing Errors
+ * Retrieves any existing errors placed in the request by previous
+ * actions. This method could be called instead of creating a <code>new
+ * ActionMessages()</code> at the beginning of an <code>Action</code>.
+ * This will prevent saveErrors() from wiping out any existing Errors
*
+ * @param request The servlet request we are processing
* @return the Errors that already exist in the request, or a new
* ActionMessages object if empty.
- * @param request The servlet request we are processing
* @since Struts 1.2.1
*/
protected ActionMessages getErrors(HttpServletRequest request) {
ActionMessages errors =
- (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
+ (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
+
if (errors == null) {
errors = new ActionMessages();
}
+
return errors;
}
-
/**
* <p>Return the user's currently selected Locale.</p>
*
@@ -318,34 +282,31 @@
* @return The user's currently selected Locale.
*/
protected Locale getLocale(HttpServletRequest request) {
-
return RequestUtils.getUserLocale(request, null);
-
}
-
/**
* Retrieves any existing messages placed in the request by previous
- * actions. This method could be called instead of creating a
- * <code>new ActionMessages()</code> at the beginning of an
- * <code>Action</code> This will prevent saveMessages() from wiping out any
- * existing Messages
+ * actions. This method could be called instead of creating a <code>new
+ * ActionMessages()</code> at the beginning of an <code>Action</code> This
+ * will prevent saveMessages() from wiping out any existing Messages
*
+ * @param request The servlet request we are processing
* @return the Messages that already exist in the request, or a new
* ActionMessages object if empty.
- * @param request The servlet request we are processing
* @since Struts 1.2.1
*/
protected ActionMessages getMessages(HttpServletRequest request) {
ActionMessages messages =
- (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY);
+ (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY);
+
if (messages == null) {
messages = new ActionMessages();
}
+
return messages;
}
-
/**
* <p>Return the default message resources for the current module.</p>
*
@@ -354,166 +315,139 @@
* @since Struts 1.1
*/
protected MessageResources getResources(HttpServletRequest request) {
-
- return ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));
-
+ return ((MessageResources) request
+ .getAttribute(Globals.MESSAGES_KEY));
}
-
/**
* <p>Return the specified message resources for the current module.</p>
*
* @param request The servlet request we are processing
- * @param key The key specified in the
- * <code><message-resources></code> element for the
- * requested bundle.
+ * @param key The key specified in the <code><message-resources></code>
+ * element for the requested bundle.
* @return The specified message resource for the current module.
- *
* @since Struts 1.1
*/
- protected MessageResources getResources(
- HttpServletRequest request,
- String key) {
-
+ protected MessageResources getResources(HttpServletRequest request,
+ String key) {
// Identify the current module
ServletContext context = getServlet().getServletContext();
ModuleConfig moduleConfig =
- ModuleUtils.getInstance().getModuleConfig(request, context);
+ ModuleUtils.getInstance().getModuleConfig(request,
+ context);
// Return the requested message resources instance
- return (MessageResources) context.getAttribute(
- key + moduleConfig.getPrefix());
-
+ return (MessageResources) context.getAttribute(key
+ + moduleConfig.getPrefix());
}
-
/**
* <p>Returns <code>true</code> if the current form's cancel button was
* pressed. This method will check if the <code>Globals.CANCEL_KEY</code>
* request attribute has been set, which normally occurs if the cancel
* button generated by <strong>CancelTag</strong> was pressed by the user
- * in the current request. If <code>true</code>, validation performed
- * by an <strong>ActionForm</strong>'s <code>validate()</code> method
- * will have been skipped by the controller servlet.</p>
+ * in the current request. If <code>true</code>, validation performed by
+ * an <strong>ActionForm</strong>'s <code>validate()</code> method will
+ * have been skipped by the controller servlet.</p>
*
* @param request The servlet request we are processing
* @return <code>true</code> if the cancel button was pressed;
* <code>false</code> otherwise.
*/
protected boolean isCancelled(HttpServletRequest request) {
-
return (request.getAttribute(Globals.CANCEL_KEY) != null);
-
}
-
/**
* <p>Return <code>true</code> if there is a transaction token stored in
* the user's current session, and the value submitted as a request
- * parameter with this action matches it. Returns <code>false</code>
- * under any of the following circumstances:</p>
- * <ul>
- * <li>No session associated with this request</li>
- * <li>No transaction token saved in the session</li>
- * <li>No transaction token included as a request parameter</li>
- * <li>The included transaction token value does not match the
- * transaction token in the user's session</li>
- * </ul>
+ * parameter with this action matches it. Returns <code>false</code> under
+ * any of the following circumstances:</p> <ul> <li>No session associated
+ * with this request</li> <li>No transaction token saved in the
+ * session</li> <li>No transaction token included as a request
+ * parameter</li> <li>The included transaction token value does not match
+ * the transaction token in the user's session</li> </ul>
*
* @param request The servlet request we are processing
* @return <code>true</code> if there is a transaction token and it is
* valid; <code>false</code> otherwise.
*/
protected boolean isTokenValid(HttpServletRequest request) {
-
return token.isTokenValid(request, false);
-
}
-
/**
* <p>Return <code>true</code> if there is a transaction token stored in
* the user's current session, and the value submitted as a request
* parameter with this action matches it. Returns <code>false</code> under
- * any of the following circumstances:</p>
- * <ul>
- * <li>No session associated with this request</li>
- * <li>No transaction token saved in the session</li>
- * <li>No transaction token included as a request parameter</li>
- * <li>The included transaction token value does not match the
- * transaction token in the user's session</li>
- * </ul>
+ * any of the following circumstances:</p> <ul> <li>No session associated
+ * with this request</li> <li>No transaction token saved in the
+ * session</li> <li>No transaction token included as a request
+ * parameter</li> <li>The included transaction token value does not match
+ * the transaction token in the user's session</li> </ul>
*
* @param request The servlet request we are processing
- * @param reset Should we reset the token after checking it?
+ * @param reset Should we reset the token after checking it?
* @return <code>true</code> if there is a transaction token and it is
* valid; <code>false</code> otherwise.
*/
- protected boolean isTokenValid(HttpServletRequest request, boolean reset) {
-
+ protected boolean isTokenValid(HttpServletRequest request,
+ boolean reset) {
return token.isTokenValid(request, reset);
-
}
-
/**
* <p>Reset the saved transaction token in the user's session. This
- * indicates that transactional token checking will not be needed
- * on the next request that is submitted.</p>
+ * indicates that transactional token checking will not be needed on the
+ * next request that is submitted.</p>
*
* @param request The servlet request we are processing
*/
protected void resetToken(HttpServletRequest request) {
-
token.resetToken(request);
-
}
-
/**
* <p>Save the specified error messages keys into the appropriate request
- * attribute for use by the <html:errors> tag, if any messages
- * are required. Otherwise, ensure that the request attribute is not
+ * attribute for use by the <html:errors> tag, if any messages are
+ * required. Otherwise, ensure that the request attribute is not
* created.</p>
*
* @param request The servlet request we are processing
- * @param errors Error messages object
+ * @param errors Error messages object
* @since Struts 1.2
*/
protected void saveErrors(HttpServletRequest request,
- ActionMessages errors) {
-
+ ActionMessages errors) {
// Remove any error messages attribute if none are required
if ((errors == null) || errors.isEmpty()) {
request.removeAttribute(Globals.ERROR_KEY);
+
return;
}
// Save the error messages we need
request.setAttribute(Globals.ERROR_KEY, errors);
-
}
-
/**
* <p>Save the specified messages keys into the appropriate request
- * attribute for use by the <html:messages> tag (if
- * messages="true" is set), if any messages are required. Otherwise,
- * ensure that the request attribute is not created.</p>
+ * attribute for use by the <html:messages> tag (if messages="true"
+ * is set), if any messages are required. Otherwise, ensure that the
+ * request attribute is not created.</p>
*
- * @param request The servlet request we are processing.
+ * @param request The servlet request we are processing.
* @param messages The messages to save. <code>null</code> or empty
- * messages removes any existing ActionMessages in the request.
- *
+ * messages removes any existing ActionMessages in the
+ * request.
* @since Struts 1.1
*/
- protected void saveMessages(
- HttpServletRequest request,
- ActionMessages messages) {
-
+ protected void saveMessages(HttpServletRequest request,
+ ActionMessages messages) {
// Remove any messages attribute if none are required
if ((messages == null) || messages.isEmpty()) {
request.removeAttribute(Globals.MESSAGE_KEY);
+
return;
}
@@ -521,26 +455,24 @@
request.setAttribute(Globals.MESSAGE_KEY, messages);
}
-
/**
* <p>Save the specified messages keys into the appropriate session
- * attribute for use by the <html:messages> tag (if
- * messages="true" is set), if any messages are required. Otherwise,
- * ensure that the session attribute is not created.</p>
+ * attribute for use by the <html:messages> tag (if messages="true"
+ * is set), if any messages are required. Otherwise, ensure that the
+ * session attribute is not created.</p>
*
- * @param session The session to save the messages in.
+ * @param session The session to save the messages in.
* @param messages The messages to save. <code>null</code> or empty
- * messages removes any existing ActionMessages in the session.
- *
+ * messages removes any existing ActionMessages in the
+ * session.
* @since Struts 1.2
*/
- protected void saveMessages(
- HttpSession session,
- ActionMessages messages) {
-
+ protected void saveMessages(HttpSession session,
+ ActionMessages messages) {
// Remove any messages attribute if none are required
if ((messages == null) || messages.isEmpty()) {
session.removeAttribute(Globals.MESSAGE_KEY);
+
return;
}
@@ -548,26 +480,23 @@
session.setAttribute(Globals.MESSAGE_KEY, messages);
}
-
/**
* <p>Save the specified error messages keys into the appropriate session
- * attribute for use by the <html:messages> tag (if messages="false")
- * or <html:errors>, if any error messages are required. Otherwise,
- * ensure that the session attribute is empty.</p>
+ * attribute for use by the <html:messages> tag (if
+ * messages="false") or <html:errors>, if any error messages are
+ * required. Otherwise, ensure that the session attribute is empty.</p>
*
* @param session The session to save the error messages in.
- * @param errors The error messages to save. <code>null</code> or empty
- * messages removes any existing error ActionMessages in the session.
- *
+ * @param errors The error messages to save. <code>null</code> or empty
+ * messages removes any existing error ActionMessages in
+ * the session.
* @since Struts 1.3
*/
- protected void saveErrors(
- HttpSession session,
- ActionMessages errors) {
-
+ protected void saveErrors(HttpSession session, ActionMessages errors) {
// Remove the error attribute if none are required
if ((errors == null) || errors.isEmpty()) {
session.removeAttribute(Globals.ERROR_KEY);
+
return;
}
@@ -575,7 +504,6 @@
session.setAttribute(Globals.ERROR_KEY, errors);
}
-
/**
* <p>Save a new transaction token in the user's current session, creating
* a new session if necessary.</p>
@@ -586,23 +514,21 @@
token.saveToken(request);
}
-
/**
* <p>Set the user's currently selected <code>Locale</code> into their
* <code>HttpSession</code>.</p>
*
* @param request The request we are processing
- * @param locale The user's selected Locale to be set, or null
- * to select the server's default Locale
+ * @param locale The user's selected Locale to be set, or null to select
+ * the server's default Locale
*/
protected void setLocale(HttpServletRequest request, Locale locale) {
-
HttpSession session = request.getSession();
+
if (locale == null) {
locale = Locale.getDefault();
}
- session.setAttribute(Globals.LOCALE_KEY, locale);
+ session.setAttribute(Globals.LOCALE_KEY, locale);
}
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/action/ActionErrors.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ActionErrors.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/ActionErrors.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/ActionErrors.java Fri Jan 20 16:19:02 2006
@@ -15,18 +15,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.action;
import java.io.Serializable;
/**
- * <p>A class that encapsulates the error messages being reported by
- * the <code>validate()</code> method of an <code>ActionForm</code>.
- * Validation errors are either global to the entire <code>ActionForm</code>
- * bean they are associated with, or they are specific to a particular
- * bean property (and, therefore, a particular input field on the corresponding
- * form).</p>
+ * <p>A class that encapsulates the error messages being reported by the
+ * <code>validate()</code> method of an <code>ActionForm</code>. Validation
+ * errors are either global to the entire <code>ActionForm</code> bean they
+ * are associated with, or they are specific to a particular bean property
+ * (and, therefore, a particular input field on the corresponding form).</p>
*
* <p>Each individual error is described by an <code>ActionMessage</code>
* object, which contains a message key (to be looked up in an appropriate
@@ -38,11 +36,10 @@
* Therefore, no synchronization is required for access to internal
* collections.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-06 18:03:30 -0400 (Sat, 06 Aug 2005)
+ * $
*/
public class ActionErrors extends ActionMessages implements Serializable {
-
-
// --------------------------------------------------------- Public Methods
/**
@@ -56,13 +53,11 @@
* Create an <code>ActionErrors</code> object initialized with the given
* messages.
*
- * @param messages The messages to be initially added to this object.
- * This parameter can be <code>null</code>.
+ * @param messages The messages to be initially added to this object. This
+ * parameter can be <code>null</code>.
* @since Struts 1.1
*/
public ActionErrors(ActionErrors messages) {
super(messages);
}
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/action/ActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ActionForm.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/ActionForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/ActionForm.java Fri Jan 20 16:19:02 2006
@@ -15,34 +15,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.action;
+import org.apache.struts.upload.MultipartRequestHandler;
-import java.io.Serializable;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
-
-import org.apache.struts.upload.MultipartRequestHandler;
-
+import java.io.Serializable;
/**
* <p>An <strong>ActionForm</strong> is a JavaBean optionally associated with
* one or more <code>ActionMappings</code>. Such a bean will have had its
- * properties initialized from the corresponding request parameters before
- * the corresponding <code>Action.execute</code> method is called.</p>
+ * properties initialized from the corresponding request parameters before the
+ * corresponding <code>Action.execute</code> method is called.</p>
*
* <p>When the properties of this bean have been populated, but before the
- * <code>execute</code> method of the <code>Action</code> is called, this bean's
- * <code>validate</code> method will be called, which gives the bean a chance
- * to verify that the properties submitted by the user are correct and valid.
- * If this method finds problems, it returns an error messages object that
- * encapsulates those problems, and the controller servlet will return control
- * to the corresponding input form. Otherwise, the <code>validate</code>
- * method returns <code>null</code>, indicating that everything is acceptable
- * and the corresponding <code>Action.execute</code> method should be
- * called.</p>
+ * <code>execute</code> method of the <code>Action</code> is called, this
+ * bean's <code>validate</code> method will be called, which gives the bean a
+ * chance to verify that the properties submitted by the user are correct and
+ * valid. If this method finds problems, it returns an error messages object
+ * that encapsulates those problems, and the controller servlet will return
+ * control to the corresponding input form. Otherwise, the
+ * <code>validate</code> method returns <code>null</code>, indicating that
+ * everything is acceptable and the corresponding <code>Action.execute</code>
+ * method should be called.</p>
*
* <p>This class must be subclassed in order to be instantiated. Subclasses
* should provide property getter and setter methods for all of the bean
@@ -51,79 +47,66 @@
* </p>
*
* <p>Because ActionForms are JavaBeans, subclasses should also implement
- * <code>Serializable</code>, as required by the JavaBean specification.
- * Some containers require that an object meet all JavaBean requirements
- * in order to use the introspection API upon which ActionForms rely.</p>
+ * <code>Serializable</code>, as required by the JavaBean specification. Some
+ * containers require that an object meet all JavaBean requirements in order
+ * to use the introspection API upon which ActionForms rely.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-12 08:14:24 -0500 (Sat, 12 Nov 2005)
+ * $
*/
-
public abstract class ActionForm implements Serializable {
-
-
// ----------------------------------------------------- Instance Variables
-
/**
* <p>The servlet instance to which we are attached.</p>
*/
protected transient ActionServlet servlet = null;
-
/**
* <p>The MultipartRequestHandler for this form, can be
* <code>null</code>.</p>
*/
protected transient MultipartRequestHandler multipartRequestHandler;
-
// ------------------------------------------------------------- Properties
-
/**
* <p>Return the servlet instance to which we are attached.</p>
*
* @return The servlet instance to which we are attached.
*/
protected ActionServlet getServlet() {
-
return (this.servlet);
-
}
-
/**
- * <p>Return the controller servlet instance to which we are attached.
- * as an <code>ActionServletWrapper</code>.</p>
- *
- * @return An instance of {@link org.apache.struts.action.ActionServletWrapper}
- * @see org.apache.struts.action.ActionServletWrapper
+ * <p>Return the controller servlet instance to which we are attached. as
+ * an <code>ActionServletWrapper</code>.</p>
+ *
+ * @return An instance of {@link ActionServletWrapper}
+ * @see ActionServletWrapper
* @since Struts 1.0.1
*/
public ActionServletWrapper getServletWrapper() {
-
return new ActionServletWrapper(getServlet());
-
}
-
/**
- * <p>Return the <code>MultipartRequestHandler</code> for this form
- * The reasoning behind this is to give form bean developers
- * control over the lifecycle of their multipart requests
- * through the use of the <code>finish</code> and/or <code>rollback</code>
- * methods of <code>MultipartRequestHandler</code>. This method will return
- * <code>null</code> if this form's enctype is not
- * "multipart/form-data".</p>
+ * <p>Return the <code>MultipartRequestHandler</code> for this form The
+ * reasoning behind this is to give form bean developers control over the
+ * lifecycle of their multipart requests through the use of the
+ * <code>finish</code> and/or <code>rollback</code> methods of
+ * <code>MultipartRequestHandler</code>. This method will return
+ * <code>null</code> if this form's enctype is not "multipart/form-data".</p>
*
- * @return The {@link org.apache.struts.upload.MultipartRequestHandler} for this form.
+ * @return The {@link org.apache.struts.upload.MultipartRequestHandler}
+ * for this form.
* @see org.apache.struts.upload.MultipartRequestHandler
*/
public MultipartRequestHandler getMultipartRequestHandler() {
return multipartRequestHandler;
}
-
/**
* <p>Set the servlet instance to which we are attached (if
* <code>servlet</code> is non-null).</p>
@@ -131,13 +114,11 @@
* @param servlet The new controller servlet, if any
*/
public void setServlet(ActionServlet servlet) {
-
this.servlet = servlet;
- // :FIXME: Should this be releasing resources?
+ // :FIXME: Should this be releasing resources?
}
-
/**
* <p>Set the Handler provided for use in dealing with file uploads.</p>
*
@@ -145,51 +126,48 @@
*/
public void setMultipartRequestHandler(
MultipartRequestHandler multipartRequestHandler) {
-
this.multipartRequestHandler = multipartRequestHandler;
-
}
// --------------------------------------------------------- Public Methods
-
/**
- * <p>>Can be used to reset all bean properties to their default state. This method is
- * called before the properties are repopulated by the controller.</p>
+ * <p>>Can be used to reset all bean properties to their default state.
+ * This method is called before the properties are repopulated by the
+ * controller.</p>
*
- * <p>The default implementation attempts to forward to the HTTP
- * version of this method.</p>
+ * <p>The default implementation attempts to forward to the HTTP version
+ * of this method.</p>
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, ServletRequest request) {
-
try {
reset(mapping, (HttpServletRequest) request);
- } catch (ClassCastException e) {
- ;//FIXME: Why would this ever happen except a null
}
-
+ catch (ClassCastException e) {
+ ; //FIXME: Why would this ever happen except a null
+ }
}
-
/**
- * <p>Can be used to reset bean properties to their default state, as needed. This method
- * is called before the properties are repopulated by the controller.</p>
+ * <p>Can be used to reset bean properties to their default state, as
+ * needed. This method is called before the properties are repopulated by
+ * the controller.</p>
*
* <p>The default implementation does nothing. In practice, the only
- * properties that need to be reset are those which represent checkboxes on
- * a session-scoped form. Otherwise, properties can be given initial values
- * where the field is declared. </p>
- *
- * <p>If the form is stored in session-scope so that values can be collected
- * over multiple requests (a "wizard"), you must be very careful of which
- * properties, if any, are reset. As mentioned, session-scope checkboxes
- * must be reset to false for any page where this property is set. This is
- * because the client does not submit a checkbox value when it is clear
- * (false). If a session-scoped checkbox is not proactively reset, it can
- * never be set to false.</p>
+ * properties that need to be reset are those which represent checkboxes
+ * on a session-scoped form. Otherwise, properties can be given initial
+ * values where the field is declared. </p>
+ *
+ * <p>If the form is stored in session-scope so that values can be
+ * collected over multiple requests (a "wizard"), you must be very careful
+ * of which properties, if any, are reset. As mentioned, session-scope
+ * checkboxes must be reset to false for any page where this property is
+ * set. This is because the client does not submit a checkbox value when
+ * it is clear (false). If a session-scoped checkbox is not proactively
+ * reset, it can never be set to false.</p>
*
* <p>This method is <strong>not</strong> the appropriate place to
* initialize form value for an "update" type page (this should be done in
@@ -201,63 +179,53 @@
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
-
// Default implementation does nothing
-
}
-
/**
- * <p>Can be used to validate the properties that have been set for this non-HTTP request,
- * and return an <code>ActionErrors</code> object that encapsulates any
- * validation errors that have been found. If no errors are found, return
- * <code>null</code> or an <code>ActionErrors</code> object with no
- * recorded error messages.</p>
+ * <p>Can be used to validate the properties that have been set for this
+ * non-HTTP request, and return an <code>ActionErrors</code> object that
+ * encapsulates any validation errors that have been found. If no errors
+ * are found, return <code>null</code> or an <code>ActionErrors</code>
+ * object with no recorded error messages.</p>
*
- * <p>The default implementation attempts to forward to the HTTP version of
- * this method.</p>
+ * <p>The default implementation attempts to forward to the HTTP version
+ * of this method.</p>
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
- * @return The set of validation errors, if validation failed; an empty set
- * or <code>null</code> if validation succeeded.
+ * @return The set of validation errors, if validation failed; an empty
+ * set or <code>null</code> if validation succeeded.
*/
public ActionErrors validate(ActionMapping mapping,
ServletRequest request) {
-
try {
return (validate(mapping, (HttpServletRequest) request));
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e) {
return (null);
}
-
}
-
/**
- * <p>Can be used to validate the properties that have been set for this HTTP request,
- * and return an <code>ActionErrors</code> object that encapsulates any
- * validation errors that have been found. If no errors are found,
- * return <code>null</code> or an <code>ActionErrors</code> object with
- * no recorded error messages.</p>
+ * <p>Can be used to validate the properties that have been set for this
+ * HTTP request, and return an <code>ActionErrors</code> object that
+ * encapsulates any validation errors that have been found. If no errors
+ * are found, return <code>null</code> or an <code>ActionErrors</code>
+ * object with no recorded error messages.</p>
*
* <p>The default implementation performs no validation and returns
- * <code>null</code>. Subclasses must override this method to provide
- * any validation they wish to perform.</p>
- *
- * @see DynaActionForm
+ * <code>null</code>. Subclasses must override this method to provide any
+ * validation they wish to perform.</p>
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
- * @return The set of validation errors, if validation failed; an empty set
- * or <code>null</code> if validation succeeded.
+ * @return The set of validation errors, if validation failed; an empty
+ * set or <code>null</code> if validation succeeded.
+ * @see DynaActionForm
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
-
return (null);
-
}
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/action/ActionFormBean.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ActionFormBean.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/ActionFormBean.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/ActionFormBean.java Fri Jan 20 16:19:02 2006
@@ -15,14 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.action;
-
import org.apache.struts.config.FormBeanConfig;
-
/**
* <p>An <strong>ActionFormBean</strong> is the definition of a form bean that
* is loaded from a <code><form-bean></code> element in the Struts
@@ -33,25 +29,21 @@
* <code>FormBeanConfig</code>.</p>
*
* <p><strong>NOTE</strong> - This class would have been deprecated and
- * replaced by <code>org.apache.struts.config.FormBeanConfig</code> except
- * for the fact that it is part of the public API that existing applications
- * are using.</p>
+ * replaced by <code>org.apache.struts.config.FormBeanConfig</code> except for
+ * the fact that it is part of the public API that existing applications are
+ * using.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-14 01:09:32 -0400 (Sat, 14 May 2005)
+ * $
*/
public class ActionFormBean extends FormBeanConfig {
-
-
/**
* <p>Construct an instance with default vaslues.</p>
*/
public ActionFormBean() {
-
super();
-
}
-
/**
* <p>Construct an instance with the specified values.</p>
*
@@ -59,12 +51,8 @@
* @param type Fully qualified class name
*/
public ActionFormBean(String name, String type) {
-
super();
setName(name);
setType(type);
-
}
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/action/ActionForward.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ActionForward.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/ActionForward.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/ActionForward.java Fri Jan 20 16:19:02 2006
@@ -15,132 +15,109 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.action;
-
import org.apache.struts.config.ForwardConfig;
-
/**
* <p>An <strong>ActionForward</strong> represents a destination to which the
- * controller, <code>RequestProcessor</code>, might be directed to
- * perform a <code>RequestDispatcher.forward</code> or
- * <code>HttpServletResponse.sendRedirect</code> to, as a result of
- * processing activities of an <code>Action</code> class. Instances of this
- * class may be created dynamically as necessary, or configured in association
- * with an <code>ActionMapping</code> instance for named lookup of potentially
- * multiple destinations for a particular mapping instance.</p>
+ * controller, <code>RequestProcessor</code>, might be directed to perform a
+ * <code>RequestDispatcher.forward</code> or <code>HttpServletResponse.sendRedirect</code>
+ * to, as a result of processing activities of an <code>Action</code> class.
+ * Instances of this class may be created dynamically as necessary, or
+ * configured in association with an <code>ActionMapping</code> instance for
+ * named lookup of potentially multiple destinations for a particular mapping
+ * instance.</p>
*
- * <p>An <code>ActionForward</code> has the following minimal set of properties.
- * Additional properties can be provided as needed by subclassses.</p>
- * <ul>
- * <li><strong>contextRelative</strong> - Should the <code>path</code>
- * value be interpreted as context-relative (instead of
- * module-relative, if it starts with a '/' character? [false]</li>
+ * <p>An <code>ActionForward</code> has the following minimal set of
+ * properties. Additional properties can be provided as needed by
+ * subclassses.</p> <ul> <li><strong>contextRelative</strong> - Should the
+ * <code>path</code> value be interpreted as context-relative (instead of
+ * module-relative, if it starts with a '/' character? [false]</li>
* <li><strong>name</strong> - Logical name by which this instance may be
- * looked up in relationship to a particular <code>ActionMapping</code>.
- * </li>
+ * looked up in relationship to a particular <code>ActionMapping</code>. </li>
* <li><strong>path</strong> - Module-relative or context-relative URI to
- * which control should be forwarded, or an absolute or relative URI to
- * which control should be redirected.</li>
- * <li><strong>redirect</strong> - Set to <code>true</code> if the controller
- * servlet should call <code>HttpServletResponse.sendRedirect()</code>
- * on the associated path; otherwise <code>false</code>. [false]</li>
- * </ul>
+ * which control should be forwarded, or an absolute or relative URI to which
+ * control should be redirected.</li> <li><strong>redirect</strong> - Set to
+ * <code>true</code> if the controller servlet should call
+ * <code>HttpServletResponse.sendRedirect()</code> on the associated path;
+ * otherwise <code>false</code>. [false]</li> </ul>
*
- * <p>Since Struts 1.1 this class extends <code>ForwardConfig</code>
- * and inherits the <code>contextRelative</code> property.
+ * <p>Since Struts 1.1 this class extends <code>ForwardConfig</code> and
+ * inherits the <code>contextRelative</code> property.
*
* <p><strong>NOTE</strong> - This class would have been deprecated and
- * replaced by <code>org.apache.struts.config.ForwardConfig</code> except
- * for the fact that it is part of the public API that existing applications
- * are using.</p>
+ * replaced by <code>org.apache.struts.config.ForwardConfig</code> except for
+ * the fact that it is part of the public API that existing applications are
+ * using.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-14 17:24:39 -0400 (Sun, 14 Aug 2005)
+ * $
*/
-
public class ActionForward extends ForwardConfig {
-
-
/**
* <p>Construct a new instance with default values.</p>
*/
public ActionForward() {
-
this(null, false);
-
}
-
/**
* <p>Construct a new instance with the specified path.</p>
*
* @param path Path for this instance
*/
public ActionForward(String path) {
-
this(path, false);
-
}
-
/**
- * <p>Construct a new instance with the specified
- * <code>path</code> and <code>redirect</code> flag.</p>
+ * <p>Construct a new instance with the specified <code>path</code> and
+ * <code>redirect</code> flag.</p>
*
- * @param path Path for this instance
+ * @param path Path for this instance
* @param redirect Redirect flag for this instance
*/
public ActionForward(String path, boolean redirect) {
-
super();
setName(null);
setPath(path);
setRedirect(redirect);
-
}
-
/**
* <p>Construct a new instance with the specified <code>name</code>,
* <code>path</code> and <code>redirect</code> flag.</p>
*
- * @param name Name of this instance
- * @param path Path for this instance
+ * @param name Name of this instance
+ * @param path Path for this instance
* @param redirect Redirect flag for this instance
*/
public ActionForward(String name, String path, boolean redirect) {
-
super();
setName(name);
setPath(path);
setRedirect(redirect);
-
}
-
/**
* Construct a new instance with the specified values.
*
- * @param name Name of this forward
- * @param path Path to which control should be forwarded or redirected
+ * @param name Name of this forward
+ * @param path Path to which control should be forwarded or
+ * redirected
* @param redirect Should we do a redirect?
- * @param module Module prefix, if any
+ * @param module Module prefix, if any
*/
public ActionForward(String name, String path, boolean redirect,
String module) {
-
super();
setName(name);
setPath(path);
setRedirect(redirect);
setModule(module);
-
}
-
/**
* <p>Construct a new instance based on the values of another
* ActionForward.</p>
@@ -152,5 +129,4 @@
this(copyMe.getName(), copyMe.getPath(), copyMe.getRedirect(),
copyMe.getModule());
}
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/action/ActionMapping.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ActionMapping.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/ActionMapping.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/ActionMapping.java Fri Jan 20 16:19:02 2006
@@ -15,23 +15,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.struts.action;
-
-import java.util.ArrayList;
-
-import org.apache.struts.config.ActionConfig;
-import org.apache.struts.config.ForwardConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.struts.config.ActionConfig;
+import org.apache.struts.config.ForwardConfig;
+import java.util.ArrayList;
/**
* <p>An <strong>ActionMapping</strong> represents the information that the
- * controller, <code>RequestProcessor</code>, knows about the mapping
- * of a particular request to an instance of a particular <code>Action</code>
+ * controller, <code>RequestProcessor</code>, knows about the mapping of a
+ * particular request to an instance of a particular <code>Action</code>
* class. The <code>ActionMapping</code> instance used to select a particular
* <code>Action</code> is passed on to that <code>Action</code>, thereby
* providing access to any custom configuration information included with the
@@ -40,16 +36,14 @@
* <p>Since Struts 1.1 this class extends <code>ActionConfig</code>.
*
* <p><strong>NOTE</strong> - This class would have been deprecated and
- * replaced by <code>org.apache.struts.config.ActionConfig</code> except
- * for the fact that it is part of the public API that existing applications
- * are using.</p>
+ * replaced by <code>org.apache.struts.config.ActionConfig</code> except for
+ * the fact that it is part of the public API that existing applications are
+ * using.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-26 21:58:39 -0400 (Fri, 26 Aug 2005)
+ * $
*/
-
public class ActionMapping extends ActionConfig {
-
-
/**
* <p>Commons Logging instance.</p>
*
@@ -57,70 +51,63 @@
*/
private static Log log = LogFactory.getLog(ActionMapping.class);
-
/**
- * <p>Find and return the <code>ForwardConfig</code> instance defining
- * how forwarding to the specified logical name should be handled. This is
+ * <p>Find and return the <code>ForwardConfig</code> instance defining how
+ * forwarding to the specified logical name should be handled. This is
* performed by checking local and then global configurations for the
- * specified forwarding configuration. If no forwarding configuration
- * can be found, return <code>null</code>.</p>
- *
- * @param forwardName Logical name of the forwarding instance to be returned
+ * specified forwarding configuration. If no forwarding configuration can
+ * be found, return <code>null</code>.</p>
*
+ * @param forwardName Logical name of the forwarding instance to be
+ * returned
* @return The local or global forward with the specified name.
*/
public ActionForward findForward(String forwardName) {
-
ForwardConfig config = findForwardConfig(forwardName);
+
if (config == null) {
config = getModuleConfig().findForwardConfig(forwardName);
}
+
if (config == null) {
if (log.isWarnEnabled()) {
log.warn("Unable to find '" + forwardName + "' forward.");
}
}
- return ((ActionForward) config);
+ return ((ActionForward) config);
}
-
/**
* <p>Return the logical names of all locally defined forwards for this
- * mapping. If there are no such forwards, a zero-length array
- * is returned.</p>
+ * mapping. If there are no such forwards, a zero-length array is
+ * returned.</p>
*
* @return The forward names for this action mapping.
*/
public String[] findForwards() {
-
ArrayList results = new ArrayList();
ForwardConfig[] fcs = findForwardConfigs();
+
for (int i = 0; i < fcs.length; i++) {
results.add(fcs[i].getName());
}
- return ((String[]) results.toArray(new String[results.size()]));
+ return ((String[]) results.toArray(new String[results.size()]));
}
-
/**
* <p>Create (if necessary) and return an {@link ActionForward} that
* corresponds to the <code>input</code> property of this Action.</p>
*
* @return The input forward for this action mapping.
- *
* @since Struts 1.1
*/
public ActionForward getInputForward() {
-
if (getModuleConfig().getControllerConfig().getInputForward()) {
return (findForward(getInput()));
} else {
return (new ActionForward(getInput()));
}
-
}
-
-
}
Modified: struts/action/trunk/src/java/org/apache/struts/action/ActionMessage.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ActionMessage.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/ActionMessage.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/ActionMessage.java Fri Jan 20 16:19:02 2006
@@ -15,26 +15,41 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.struts.action;
import java.io.Serializable;
/**
* <p>An encapsulation of an individual message returned by the
- * <code>validate</code> method of an <code>ActionForm</code>, consisting
- * of a message key (to be used to look up message text in an appropriate
- * message resources database) plus up to four placeholder objects that can
- * be used for parametric replacement in the message text.</p>
+ * <code>validate</code> method of an <code>ActionForm</code>, consisting of a
+ * message key (to be used to look up message text in an appropriate message
+ * resources database) plus up to four placeholder objects that can be used
+ * for parametric replacement in the message text.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-14 01:09:32 -0400 (Sat, 14 May 2005)
+ * $
* @since Struts 1.1
*/
public class ActionMessage implements Serializable {
+ // ----------------------------------------------------- Instance Variables
+ /**
+ * <p>The message key for this message.</p>
+ */
+ protected String key = null;
- // ----------------------------------------------------------- Constructors
+ /**
+ * <p>The replacement values for this mesasge.</p>
+ */
+ protected Object[] values = null;
+ /**
+ * <p>Indicates whether the key is taken to be as a bundle key [true] or
+ * literal value [false].</p>
+ */
+ protected boolean resource = true;
+
+ // ----------------------------------------------------------- Constructors
/**
* <p>Construct an action message with no replacement values.</p>
@@ -45,149 +60,113 @@
this(key, null);
}
-
/**
- * <p>Construct an action message with the specified replacement values.</p>
+ * <p>Construct an action message with the specified replacement
+ * values.</p>
*
- * @param key Message key for this message
+ * @param key Message key for this message
* @param value0 First replacement value
*/
public ActionMessage(String key, Object value0) {
- this(key, new Object[] {value0});
+ this(key, new Object[]{value0});
}
-
/**
- * <p>Construct an action message with the specified replacement values.</p>
+ * <p>Construct an action message with the specified replacement
+ * values.</p>
*
- * @param key Message key for this message
+ * @param key Message key for this message
* @param value0 First replacement value
* @param value1 Second replacement value
*/
public ActionMessage(String key, Object value0, Object value1) {
- this(key, new Object[] {value0, value1});
+ this(key, new Object[]{value0, value1});
}
-
/**
- * <p>Construct an action message with the specified replacement values.</p>
+ * <p>Construct an action message with the specified replacement
+ * values.</p>
*
- * @param key Message key for this message
+ * @param key Message key for this message
* @param value0 First replacement value
* @param value1 Second replacement value
* @param value2 Third replacement value
*/
public ActionMessage(String key, Object value0, Object value1,
- Object value2) {
-
- this(key, new Object[] {value0, value1, value2});
+ Object value2) {
+ this(key, new Object[]{value0, value1, value2});
}
-
/**
- * <p>Construct an action message with the specified replacement values.</p>
+ * <p>Construct an action message with the specified replacement
+ * values.</p>
*
- * @param key Message key for this message
+ * @param key Message key for this message
* @param value0 First replacement value
* @param value1 Second replacement value
* @param value2 Third replacement value
* @param value3 Fourth replacement value
*/
public ActionMessage(String key, Object value0, Object value1,
- Object value2, Object value3) {
-
- this(key, new Object[] {value0, value1, value2, value3});
+ Object value2, Object value3) {
+ this(key, new Object[]{value0, value1, value2, value3});
}
-
/**
- * <p>Construct an action message with the specified replacement values.</p>
+ * <p>Construct an action message with the specified replacement
+ * values.</p>
*
- * @param key Message key for this message
+ * @param key Message key for this message
* @param values Array of replacement values
*/
public ActionMessage(String key, Object[] values) {
-
this.key = key;
this.values = values;
this.resource = true;
-
}
/**
- * <p>Construct an action message with the specified replacement values.</p>
+ * <p>Construct an action message with the specified replacement
+ * values.</p>
*
- * @param key Message key for this message
+ * @param key Message key for this message
* @param resource Indicates whether the key is a bundle key or literal
* value
*/
public ActionMessage(String key, boolean resource) {
-
this.key = key;
this.resource = resource;
-
}
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * <p>The message key for this message.</p>
- */
- protected String key = null;
-
-
- /**
- * <p>The replacement values for this mesasge.</p>
- */
- protected Object[] values = null;
-
- /**
- * <p>Indicates whether the key is taken to be as a bundle key [true] or
- * literal value [false].</p>
- */
- protected boolean resource = true;
-
-
// --------------------------------------------------------- Public Methods
-
/**
* <p>Get the message key for this message.</p>
*
* @return The message key for this message.
*/
public String getKey() {
-
return (this.key);
-
}
-
/**
* <p>Get the replacement values for this message.</p>
*
* @return The replacement values for this message.
*/
public Object[] getValues() {
-
return (this.values);
-
}
-
/**
* <p>Indicate whether the key is taken to be as a bundle key [true] or
* literal value [false].</p>
*
- * @return <code>true</code> if the key is a bundle key; <code>false</code>
- * otherwise.
+ * @return <code>true</code> if the key is a bundle key;
+ * <code>false</code> otherwise.
*/
public boolean isResource() {
-
return (this.resource);
-
}
/**
@@ -197,20 +176,18 @@
*/
public String toString() {
StringBuffer buff = new StringBuffer();
+
buff.append(this.key);
buff.append("[");
if (this.values != null) {
-
for (int i = 0; i < this.values.length; i++) {
-
buff.append(this.values[i]);
// don't append comma to last entry
- if (i < this.values.length - 1) {
+ if (i < (this.values.length - 1)) {
buff.append(", ");
}
-
}
}
@@ -218,6 +195,4 @@
return buff.toString();
}
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org