Modified: struts/extras/trunk/src/java/org/apache/struts/actions/MappingDispatchAction.java URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/MappingDispatchAction.java?rev=376812&r1=376811&r2=376812&view=diff ============================================================================== --- struts/extras/trunk/src/java/org/apache/struts/actions/MappingDispatchAction.java (original) +++ struts/extras/trunk/src/java/org/apache/struts/actions/MappingDispatchAction.java Fri Feb 10 11:42:38 2006 @@ -15,27 +15,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.struts.actions; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + /** - * <p>An abstract <strong>Action</strong> that dispatches to a public - * method that is named by the <code>parameter</code> attribute of - * the corresponding ActionMapping. This is useful for developers who prefer - * to combine many related actions into a single Action class.</p> + * <p>An abstract <strong>Action</strong> that dispatches to a public method + * that is named by the <code>parameter</code> attribute of the corresponding + * ActionMapping. This is useful for developers who prefer to combine many + * related actions into a single Action class.</p> * - * <p>To configure the use of this action in your - * <code>struts-config.xml</code> file, create an entry like this:</p> + * <p>To configure the use of this action in your <code>struts-config.xml</code> + * file, create an entry like this:</p> * * <pre><code> * <action path="/saveSubscription" @@ -47,27 +46,35 @@ * </code></pre> * * <p>where 'method' is the name of a method in your subclass of - * MappingDispatchAction that has the same signature (other than method - * name) of the standard Action.execute method. For example, you might combine - * the methods for managing a subscription into a single - * MappingDispatchAction class using the following methods:</p> + * MappingDispatchAction that has the same signature (other than method name) + * of the standard Action.execute method. For example, you might combine the + * methods for managing a subscription into a single MappingDispatchAction + * class using the following methods:</p> + * * <ul> + * * <li>public ActionForward create(ActionMapping mapping, ActionForm form, - * HttpServletRequest request, HttpServletResponse response) - * throws Exception</li> + * HttpServletRequest request, HttpServletResponse response) throws + * Exception</li> + * * <li>public ActionForward edit(ActionMapping mapping, ActionForm form, - * HttpServletRequest request, HttpServletResponse response) - * throws Exception</li> + * HttpServletRequest request, HttpServletResponse response) throws + * Exception</li> + * * <li>public ActionForward save(ActionMapping mapping, ActionForm form, - * HttpServletRequest request, HttpServletResponse response) - * throws Exception</li> + * HttpServletRequest request, HttpServletResponse response) throws + * Exception</li> + * * <li>public ActionForward delete(ActionMapping mapping, ActionForm form, - * HttpServletRequest request, HttpServletResponse response) - * throws Exception</li> + * HttpServletRequest request, HttpServletResponse response) throws + * Exception</li> + * * <li>public ActionForward list(ActionMapping mapping, ActionForm form, - * HttpServletRequest request, HttpServletResponse response) - * throws Exception</li> + * HttpServletRequest request, HttpServletResponse response) throws + * Exception</li> + * * </ul> + * * <p>for which you would create corresponding <action> configurations * that reference this class:</p> * @@ -114,28 +121,22 @@ * may differ between the various handlers, so you can combine actions in the * same class that, for example, differ in their use of forms or validation. * Also, a request parameter, which would be visible to the application user, - * is not required to enable selection of the handler method. - * </p> + * is not required to enable selection of the handler method. </p> * - * @version $Rev$ $Date$ + * @version $Rev$ $Date: 2005-05-14 21:27:02 -0400 (Sat, 14 May 2005) + * $ * @since Struts 1.2 */ public class MappingDispatchAction extends DispatchAction { - - // -------------------------------------------------------- Class Variables - /** * Commons Logging instance. */ - private static Log log = - LogFactory.getLog(MappingDispatchAction.class); - + private static Log log = LogFactory.getLog(MappingDispatchAction.class); // --------------------------------------------------------- Public Methods - /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). @@ -147,54 +148,40 @@ * <code>MappingDispatchAction</code> using the 'parameter' attribute of * <code>ActionMapping</code> and Java Introspection. * - * @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 Return an <code>ActionForward</code> instance describing where - * and how control should be forwarded, or <code>null</code> if - * the response has already been completed. - * - * @exception Exception if an exception occurs + * @return Return an <code>ActionForward</code> instance describing where + * and how control should be forwarded, or <code>null</code> if + * the response has already been completed. + * @throws Exception if an exception occurs */ - public ActionForward execute( - ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws Exception { - // Use the overridden getMethodName. return super.execute(mapping, form, request, response); } - /** - * Method which is dispatched to when there is no value for the - * parameter in the ActionMapping. Subclasses of - * <code>MappingDispatchAction</code> should override this method - * if they wish to provide default behavior different than throwing a - * ServletException. - * - * @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 + * Method which is dispatched to when there is no value for the parameter + * in the ActionMapping. Subclasses of <code>MappingDispatchAction</code> + * should override this method if they wish to provide default behavior + * different than throwing a ServletException. + * + * @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 Return an <code>ActionForward</code> instance describing where - * and how control should be forwarded, or <code>null</code> if - * the response has already been completed. - * - * @exception Exception if an exception occurs + * @return Return an <code>ActionForward</code> instance describing where + * and how control should be forwarded, or <code>null</code> if + * the response has already been completed. + * @throws Exception if an exception occurs */ - protected ActionForward unspecified( - ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws Exception { - String message = messages.getMessage("mapping.parameter", mapping.getPath()); @@ -206,28 +193,20 @@ /** * Returns the method name, given a parameter's value. * - * @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 + * @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 * @param parameter The <code>ActionMapping</code> parameter's name - * * @return The method's name. - * * @throws Exception if an error occurs - * * @since Struts 1.2.0 */ - protected String getMethodName( - ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response, - String parameter) - throws Exception { - + protected String getMethodName(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response, + String parameter) throws Exception { // Return the unresolved mapping parameter. return parameter; } - }
Modified: struts/extras/trunk/src/java/org/apache/struts/actions/SwitchAction.java URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/SwitchAction.java?rev=376812&r1=376811&r2=376812&view=diff ============================================================================== --- struts/extras/trunk/src/java/org/apache/struts/actions/SwitchAction.java (original) +++ struts/extras/trunk/src/java/org/apache/struts/actions/SwitchAction.java Fri Feb 10 11:42:38 2006 @@ -15,13 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.struts.actions; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.Globals; @@ -30,38 +25,42 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.util.ModuleUtils; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + /** - * <p>A standard <strong>Action</strong> that switches to a new module - * and then forwards control to a URI (specified in a number of possible ways) + * <p>A standard <strong>Action</strong> that switches to a new module and + * then forwards control to a URI (specified in a number of possible ways) * within the new module.</p> * * <p>Valid request parameters for this Action are:</p> + * * <ul> - * <li><strong>page</strong> - Module-relative URI (beginning with "/") - * to which control should be forwarded after switching.</li> - * <li><strong>prefix</strong> - The module prefix (beginning with "/") - * of the module to which control should be switched. Use a - * zero-length string for the default module. The - * appropriate <code>ModuleConfig</code> object will be stored as a - * request attribute, so any subsequent logic will assume the new - * module.</li> + * + * <li><strong>page</strong> - Module-relative URI (beginning with "/") to + * which control should be forwarded after switching.</li> + * + * <li><strong>prefix</strong> - The module prefix (beginning with "/") of the + * module to which control should be switched. Use a zero-length string for + * the default module. The appropriate <code>ModuleConfig</code> object will + * be stored as a request attribute, so any subsequent logic will assume the + * new module.</li> + * * </ul> * - * @version $Rev$ $Date$ + * @version $Rev$ $Date: 2005-05-14 21:27:02 -0400 (Sat, 14 May 2005) + * $ * @since Struts 1.1 */ public class SwitchAction extends BaseAction { - - // ----------------------------------------------------- Instance Variables - /** * Commons Logging instance. */ protected static Log log = LogFactory.getLog(SwitchAction.class); - /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). @@ -69,46 +68,41 @@ * control should be forwarded, or <code>null</code> if the response has * already been completed. * - * @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 Return an <code>ActionForward</code> instance describing where - * and how control should be forwarded, or <code>null</code> if - * the response has already been completed. - * - * @exception Exception if an exception occurs + * @return Return an <code>ActionForward</code> instance describing where + * and how control should be forwarded, or <code>null</code> if + * the response has already been completed. + * @throws Exception if an exception occurs */ - public ActionForward execute(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws Exception { - // Identify the request parameters controlling our actions String page = request.getParameter("page"); String prefix = request.getParameter("prefix"); + if ((page == null) || (prefix == null)) { String message = messages.getMessage("switch.required"); + log.error(message); throw new ServletException(message); } // Switch to the requested module ModuleUtils.getInstance().selectModule(prefix, request, - getServlet().getServletContext()); + getServlet().getServletContext()); if (request.getAttribute(Globals.MODULE_KEY) == null) { String message = messages.getMessage("switch.prefix", prefix); + log.error(message); throw new ServletException(message); } // Forward control to the specified module-relative URI return (new ActionForward(page)); - } - - } Modified: struts/extras/trunk/src/java/org/apache/struts/actions/package.html URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/package.html?rev=376812&r1=376811&r2=376812&view=diff ============================================================================== --- struts/extras/trunk/src/java/org/apache/struts/actions/package.html (original) +++ struts/extras/trunk/src/java/org/apache/struts/actions/package.html Fri Feb 10 11:42:38 2006 @@ -2,31 +2,32 @@ <html> <head> </head> - <body bgcolor="white"> - -<p> The actions package provides special adapters between the incoming HTTP - request and the corresponding business logic.</p> - <br> - <br> - <img src="doc-files/actionsUML.gif" alt="Action Package UML" > - <br> - + +<body bgcolor="white"> + +<p> The actions package provides special adapters between the incoming HTTP + request and the corresponding business logic.</p> +<br> +<br> +<img src="doc-files/actionsUML.gif" alt="Action Package UML"> +<br> + <h2>Package Specification</h2> - ##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### +##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### <ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> - </li> - + <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> + </li> + </ul> - + <h2>Related Documentation</h2> - For overviews, tutorials, examples, guides, and tool documentation, -please see: +For overviews, tutorials, examples, guides, and tool documentation, +please see: <ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> - </li> - + <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> + </li> + </ul> - <!-- Put @see and @since tags down here. --> +<!-- Put @see and @since tags down here. --> </body> </html> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]