dgraham 2003/08/16 11:33:24 Modified: src/validator/org/apache/struts/webapp/validator TypeAction.java RegistrationAction.java MultiRegistrationAction.java Log: Formatted, removed unused variables, bad imports. Revision Changes Path 1.4 +38 -41 jakarta-struts/src/validator/org/apache/struts/webapp/validator/TypeAction.java Index: TypeAction.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/validator/org/apache/struts/webapp/validator/TypeAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TypeAction.java 9 Oct 2002 14:14:12 -0000 1.3 +++ TypeAction.java 16 Aug 2003 18:33:24 -0000 1.4 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,32 +52,29 @@ * <http://www.apache.org/>. */ - package org.apache.struts.webapp.validator; -import java.util.Locale; -import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.util.MessageResources; - /** * Implementation of <strong>Action</strong> that validates a different 'types'. * * @author David Wintefeldt -*/ + */ public final class TypeAction extends Action { /** * Commons Logging instance. - */ + */ private Log log = LogFactory.getFactory().getInstance(this.getClass().getName()); /** @@ -95,31 +92,28 @@ * @return Action to forward to * @exception Exception if an input/output error or servlet exception occurs */ - public ActionForward execute(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - throws Exception { - - // Extract attributes we will need - HttpSession session = request.getSession(); - Locale locale = getLocale(request); - MessageResources messages = getResources(request); - TypeForm info = (TypeForm)form; - String action = request.getParameter("action"); - - // Was this transaction cancelled? - if (isCancelled(request)) { - if (log.isInfoEnabled()) { - log.info(" " + mapping.getAttribute() + " - Type transaction was cancelled"); - } + public ActionForward execute( + ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) + throws Exception { + + // Was this transaction cancelled? + if (isCancelled(request)) { + if (log.isInfoEnabled()) { + log.info( + " " + + mapping.getAttribute() + + " - Type transaction was cancelled"); + } - removeFormBean(mapping, request); + removeFormBean(mapping, request); - return (mapping.findForward("success")); - } + return mapping.findForward("success"); + } - return mapping.findForward("success"); + return mapping.findForward("success"); } /** @@ -127,16 +121,19 @@ * * @param mapping The ActionMapping used to select this instance * @param request The HTTP request we are processing - */ - protected void removeFormBean(ActionMapping mapping, HttpServletRequest request) { - // Remove the obsolete form bean - if (mapping.getAttribute() != null) { - if ("request".equals(mapping.getScope())) { - request.removeAttribute(mapping.getAttribute()); - } else { - HttpSession session = request.getSession(); - session.removeAttribute(mapping.getAttribute()); - } - } + */ + protected void removeFormBean( + ActionMapping mapping, + HttpServletRequest request) { + + // Remove the obsolete form bean + if (mapping.getAttribute() != null) { + if ("request".equals(mapping.getScope())) { + request.removeAttribute(mapping.getAttribute()); + } else { + HttpSession session = request.getSession(); + session.removeAttribute(mapping.getAttribute()); + } + } } } 1.4 +38 -41 jakarta-struts/src/validator/org/apache/struts/webapp/validator/RegistrationAction.java Index: RegistrationAction.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/validator/org/apache/struts/webapp/validator/RegistrationAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RegistrationAction.java 9 Oct 2002 14:14:12 -0000 1.3 +++ RegistrationAction.java 16 Aug 2003 18:33:24 -0000 1.4 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,32 +52,29 @@ * <http://www.apache.org/>. */ - package org.apache.struts.webapp.validator; -import java.util.Locale; -import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.util.MessageResources; - /** * Implementation of <strong>Action</strong> that validates a registration form. * * @author David Wintefeldt -*/ + */ public final class RegistrationAction extends Action { /** * Commons Logging instance. - */ + */ private Log log = LogFactory.getFactory().getInstance(this.getClass().getName()); /** @@ -95,31 +92,28 @@ * @return Action to forward to * @exception Exception if an input/output error or servlet exception occurs */ - public ActionForward execute(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - throws Exception { - - // Extract attributes we will need - HttpSession session = request.getSession(); - Locale locale = getLocale(request); - MessageResources messages = getResources(request); - RegistrationForm info = (RegistrationForm)form; - String action = request.getParameter("action"); - - // Was this transaction cancelled? - if (isCancelled(request)) { - if (log.isInfoEnabled()) { - log.info(" " + mapping.getAttribute() + " - Registration transaction was cancelled"); - } + public ActionForward execute( + ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) + throws Exception { + + // Was this transaction cancelled? + if (isCancelled(request)) { + if (log.isInfoEnabled()) { + log.info( + " " + + mapping.getAttribute() + + " - Registration transaction was cancelled"); + } - removeFormBean(mapping, request); + removeFormBean(mapping, request); - return (mapping.findForward("success")); - } + return (mapping.findForward("success")); + } - return mapping.findForward("success"); + return mapping.findForward("success"); } /** @@ -127,16 +121,19 @@ * * @param mapping The ActionMapping used to select this instance * @param request The HTTP request we are processing - */ - protected void removeFormBean(ActionMapping mapping, HttpServletRequest request) { - // Remove the obsolete form bean - if (mapping.getAttribute() != null) { - if ("request".equals(mapping.getScope())) { - request.removeAttribute(mapping.getAttribute()); - } else { - HttpSession session = request.getSession(); - session.removeAttribute(mapping.getAttribute()); - } - } + */ + protected void removeFormBean( + ActionMapping mapping, + HttpServletRequest request) { + + // Remove the obsolete form bean + if (mapping.getAttribute() != null) { + if ("request".equals(mapping.getScope())) { + request.removeAttribute(mapping.getAttribute()); + } else { + HttpSession session = request.getSession(); + session.removeAttribute(mapping.getAttribute()); + } + } } } 1.5 +58 -55 jakarta-struts/src/validator/org/apache/struts/webapp/validator/MultiRegistrationAction.java Index: MultiRegistrationAction.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/validator/org/apache/struts/webapp/validator/MultiRegistrationAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MultiRegistrationAction.java 12 Nov 2002 03:56:09 -0000 1.4 +++ MultiRegistrationAction.java 16 Aug 2003 18:33:24 -0000 1.5 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,13 +52,12 @@ * <http://www.apache.org/>. */ - package org.apache.struts.webapp.validator; -import java.util.Locale; -import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.Action; @@ -66,23 +65,20 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.util.MessageResources; - /** * Implementation of <strong>Action</strong> that validates a multi-page * registration form. * * @author David Wintefeldt -*/ + */ public final class MultiRegistrationAction extends Action { /** * Commons Logging instance. - */ + */ private Log log = LogFactory.getFactory().getInstance(this.getClass().getName()); - /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). @@ -97,46 +93,50 @@ * * @exception Exception if an input/output error or servlet exception occurs */ - public ActionForward execute(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - throws Exception { - - // Extract attributes we will need - HttpSession session = request.getSession(); - Locale locale = getLocale(request); - MessageResources messages = getResources(request); - RegistrationForm info = (RegistrationForm)form; - String action = request.getParameter("action"); - - // Was this transaction cancelled? - if (isCancelled(request)) { - if (log.isInfoEnabled()) { - log.info(" " + mapping.getAttribute() + " - Registration transaction was cancelled"); - } + public ActionForward execute( + ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) + throws Exception { + + // Extract attributes we will need + RegistrationForm info = (RegistrationForm) form; + + + // Was this transaction cancelled? + if (isCancelled(request)) { + if (log.isInfoEnabled()) { + log.info( + " " + + mapping.getAttribute() + + " - Registration transaction was cancelled"); + } - removeFormBean(mapping, request); + removeFormBean(mapping, request); - return (mapping.findForward("success")); - } + return (mapping.findForward("success")); + } - ActionErrors errors = info.validate(mapping, request); + ActionErrors errors = info.validate(mapping, request); - if (errors != null && errors.isEmpty()) { - if (info.getPage() == 1) - return mapping.findForward("input2"); - if (info.getPage() == 2) - return mapping.findForward("success"); - } else { - saveErrors(request, errors); - if (info.getPage() == 1) - return mapping.findForward("input" + info.getPage()); - if (info.getPage() == 2) - return mapping.findForward("input" + info.getPage()); - } + if (errors != null && errors.isEmpty()) { + if (info.getPage() == 1) + return mapping.findForward("input2"); + + if (info.getPage() == 2) + return mapping.findForward("success"); + + } else { + saveErrors(request, errors); + if (info.getPage() == 1) + return mapping.findForward("input" + info.getPage()); + + if (info.getPage() == 2) + return mapping.findForward("input" + info.getPage()); + } - return mapping.findForward("input1"); + return mapping.findForward("input1"); } /** @@ -144,16 +144,19 @@ * * @param mapping The ActionMapping used to select this instance * @param request The HTTP request we are processing - */ - protected void removeFormBean(ActionMapping mapping, HttpServletRequest request) { - // Remove the obsolete form bean - if (mapping.getAttribute() != null) { - if ("request".equals(mapping.getScope())) { - request.removeAttribute(mapping.getAttribute()); - } else { - HttpSession session = request.getSession(); - session.removeAttribute(mapping.getAttribute()); - } - } + */ + protected void removeFormBean( + ActionMapping mapping, + HttpServletRequest request) { + + // Remove the obsolete form bean + if (mapping.getAttribute() != null) { + if ("request".equals(mapping.getScope())) { + request.removeAttribute(mapping.getAttribute()); + } else { + HttpSession session = request.getSession(); + session.removeAttribute(mapping.getAttribute()); + } + } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]