husted      2002/06/25 11:26:57

  Modified:    src/validator/org/apache/struts/webapp/validator
                        TypeAction.java RegistrationAction.java
                        MultiRegistrationAction.java LocaleAction.java
  Log:
  Updates for execute versus perform.
  
  Revision  Changes    Path
  1.2       +25 -26    
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeAction.java   19 Mar 2002 03:33:58 -0000      1.1
  +++ TypeAction.java   25 Jun 2002 18:26:57 -0000      1.2
  @@ -94,34 +94,33 @@
        * @param request The HTTP request we are processing
        * @param response The HTTP response we are creating
        *
  -     * @exception IOException if an input/output error occurs
  -     * @exception ServletException if a servlet exception occurs
  +     * @exception Exception if an input/output error or servlet exception occurs
        */
  -    public ActionForward perform(ActionMapping mapping,
  -                              ActionForm form,
  -                              HttpServletRequest request,
  -                              HttpServletResponse response)
  -     throws IOException, ServletException {
  -
  -     // Extract attributes we will need
  -     HttpSession session = request.getSession();
  -     Locale locale = getLocale(request);
  -     MessageResources messages = getResources();
  -     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");
  -         }
  -         
  -         removeFormBean(mapping, request);
  +    public ActionForward execute(ActionMapping mapping,
  +                 ActionForm form,
  +                 HttpServletRequest request,
  +                 HttpServletResponse response)
  +    throws Exception {
   
  -         return (mapping.findForward("success"));
  -     }
  +    // Extract attributes we will need
  +    HttpSession session = request.getSession();
  +    Locale locale = getLocale(request);
  +    MessageResources messages = getResources();
  +    TypeForm info = (TypeForm)form;
  +    String action = request.getParameter("action");
   
  -     return mapping.findForward("success");  
  +    // Was this transaction cancelled?
  +    if (isCancelled(request)) {
  +        if (log.isInfoEnabled()) {
  +           log.info(" " + mapping.getAttribute() + " - Type transaction was 
cancelled");
  +        }
  +
  +        removeFormBean(mapping, request);
  +
  +        return (mapping.findForward("success"));
  +    }
  +
  +    return mapping.findForward("success");
       }
   
       /**
  @@ -129,7 +128,7 @@
        *
        * @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) {
  
  
  
  1.2       +25 -26    
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RegistrationAction.java   19 Mar 2002 03:33:58 -0000      1.1
  +++ RegistrationAction.java   25 Jun 2002 18:26:57 -0000      1.2
  @@ -94,34 +94,33 @@
        * @param request The HTTP request we are processing
        * @param response The HTTP response we are creating
        *
  -     * @exception IOException if an input/output error occurs
  -     * @exception ServletException if a servlet exception occurs
  +     * @exception Exception if an input/output error or servlet exception occurs
        */
  -    public ActionForward perform(ActionMapping mapping,
  -                              ActionForm form,
  -                              HttpServletRequest request,
  -                              HttpServletResponse response)
  -     throws IOException, ServletException {
  -
  -     // Extract attributes we will need
  -     HttpSession session = request.getSession();
  -     Locale locale = getLocale(request);
  -     MessageResources messages = getResources();
  -     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");
  -         }
  -         
  -         removeFormBean(mapping, request);
  +    public ActionForward execute(ActionMapping mapping,
  +                 ActionForm form,
  +                 HttpServletRequest request,
  +                 HttpServletResponse response)
  +    throws Exception {
   
  -         return (mapping.findForward("success"));
  -     }
  +    // Extract attributes we will need
  +    HttpSession session = request.getSession();
  +    Locale locale = getLocale(request);
  +    MessageResources messages = getResources();
  +    RegistrationForm info = (RegistrationForm)form;
  +    String action = request.getParameter("action");
   
  -     return mapping.findForward("success");
  +    // Was this transaction cancelled?
  +    if (isCancelled(request)) {
  +        if (log.isInfoEnabled()) {
  +           log.info(" " + mapping.getAttribute() + " - Registration transaction was 
cancelled");
  +        }
  +
  +        removeFormBean(mapping, request);
  +
  +        return (mapping.findForward("success"));
  +    }
  +
  +    return mapping.findForward("success");
       }
   
       /**
  @@ -129,7 +128,7 @@
        *
        * @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) {
  
  
  
  1.2       +43 -44    
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultiRegistrationAction.java      19 Mar 2002 03:33:58 -0000      1.1
  +++ MultiRegistrationAction.java      25 Jun 2002 18:26:57 -0000      1.2
  @@ -72,7 +72,7 @@
   
   
   /**
  - * Implementation of <strong>Action</strong> that validates a multi-page 
  + * Implementation of <strong>Action</strong> that validates a multi-page
    * registration form.
    *
    * @author David Wintefeldt
  @@ -97,49 +97,48 @@
        * @param request The HTTP request we are processing
        * @param response The HTTP response we are creating
        *
  -     * @exception IOException if an input/output error occurs
  -     * @exception ServletException if a servlet exception occurs
  +     * @exception Exception if an input/output error or servlet exception occurs
        */
  -    public ActionForward perform(ActionMapping mapping,
  -                              ActionForm form,
  -                              HttpServletRequest request,
  -                              HttpServletResponse response)
  -     throws IOException, ServletException {
  -
  -     // Extract attributes we will need
  -     HttpSession session = request.getSession();
  -     Locale locale = getLocale(request);
  -     MessageResources messages = getResources();
  -     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");
  -         }
  -         
  -         removeFormBean(mapping, request);
  -
  -         return (mapping.findForward("success"));
  -     }
  -
  -     ActionErrors errors = info.validate(mapping, request);
  -
  -     if (errors != null && errors.empty()) {
  -        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");   
  +    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();
  +    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");
  +        }
  +
  +        removeFormBean(mapping, request);
  +
  +        return (mapping.findForward("success"));
  +    }
  +
  +    ActionErrors errors = info.validate(mapping, request);
  +
  +    if (errors != null && errors.empty()) {
  +       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");
       }
   
       /**
  @@ -147,7 +146,7 @@
        *
        * @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) {
  
  
  
  1.2       +24 -25    
jakarta-struts/src/validator/org/apache/struts/webapp/validator/LocaleAction.java
  
  Index: LocaleAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/validator/org/apache/struts/webapp/validator/LocaleAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocaleAction.java 19 Mar 2002 03:33:58 -0000      1.1
  +++ LocaleAction.java 25 Jun 2002 18:26:57 -0000      1.2
  @@ -72,8 +72,8 @@
   
   
   /**
  - * Implementation of <strong>Action</strong> that 
  - * changes a locale based on request level parameters 
  + * Implementation of <strong>Action</strong> that
  + * changes a locale based on request level parameters
    * that are set (language &amp; country).
    *
    * @author David Wintefeldt
  @@ -97,41 +97,40 @@
        * @param request The HTTP request we are processing
        * @param response The HTTP response we are creating
        *
  -     * @exception IOException if an input/output error occurs
  -     * @exception ServletException if a servlet exception occurs
  +     * @exception Exception if an input/output error or servlet exception occurs
        */
  -    public ActionForward perform(ActionMapping mapping,
  -                              ActionForm form,
  -                              HttpServletRequest request,
  -                              HttpServletResponse response)
  -     throws IOException, ServletException {
  -
  -     // Extract attributes we will need
  -     HttpSession session = request.getSession();
  -     Locale locale = getLocale(request);
  -     
  -     String language = null;
  -     String country = null;
  -     
  -     try {
  -        language = (String)
  +    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);
  +
  +    String language = null;
  +    String country = null;
  +
  +    try {
  +       language = (String)
                 PropertyUtils.getSimpleProperty(form, "language");
              country = (String)
                 PropertyUtils.getSimpleProperty(form, "country");
           } catch (Exception e) {
  -           log.error(e.getMessage(), e);     
  +           log.error(e.getMessage(), e);
           }
  -     
  +
           if ((language != null && language.length() > 0) &&
               (country != null && country.length() > 0)) {
              locale = new java.util.Locale(language, country);
           } else if (language != null && language.length() > 0) {
              locale = new java.util.Locale(language, "");
  -     }
  -        
  +    }
  +
           session.setAttribute(Action.LOCALE_KEY, locale);
  -        
  -     return mapping.findForward("success");  
  +
  +    return mapping.findForward("success");
       }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to