dwinterfeldt    02/03/18 19:33:59

  Added:       src/validator/org/apache/struts/webapp/validator
                        ApplicationResources.properties
                        ApplicationResources_fr.properties
                        CityStateZip.java LocaleAction.java
                        MultiRegistrationAction.java
                        RegistrationAction.java RegistrationForm.java
                        TypeAction.java TypeForm.java
  Log:
  Intial checkin for Validator example webapp.
  
  Revision  Changes    Path
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/ApplicationResources.properties
  
  Index: ApplicationResources.properties
  ===================================================================
  button.cancel=Cancel
  button.confirm=Confirm
  button.reset=Reset
  button.save=Save
  
  # Errors
  errors.footer=
  errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the 
following error(s) before proceeding:
  errors.ioException=I/O exception rendering error messages: {0}
  error.database.missing=<li>User database is missing, cannot validate logon 
credentials</li>
  errors.required={0} is required.
  errors.minlength={0} can not be less than {1} characters.
  errors.maxlength={0} can not be greater than {1} characters.
  errors.invalid={0} is invalid.
  
  errors.byte={0} must be an byte.
  errors.short={0} must be an short.
  errors.integer={0} must be an integer.
  errors.long={0} must be an long.
  errors.float={0} must be an float.
  errors.double={0} must be an double.
  
  errors.date={0} is not a date.
  
  errors.range={0} is not in the range {1} through {2}.
  
  errors.creditcard={0} is not a valid credit card number.
  
  errors.email={0} is an invalid e-mail address.
  
  # Index Page
  index.title=Struts Validator
  index.power=Powered by Struts
  
  # Registration Form                                     
  registrationForm.title=Registration
  registrationForm.title.create=Register
  registrationForm.title.edit=Edit User Information
  registrationForm.firstname.displayname=First Name
  registrationForm.lastname.displayname=Last Name
  registrationForm.addr.displayname=Address
  registrationForm.city.displayname=City
  registrationForm.stateprov.displayname=State
  registrationForm.zippostal.displayname=Zip
  registrationForm.phone.displayname=Phone
  registrationForm.email.displayname=E-mail
  registrationForm.lastname.maskmsg=Last Name can only be letters, no spaces.
  
  # JavaScript Registration Form
  jsRegistrationForm.title=JavaScript Registration Form
  jsRegistrationForm.description=with client side JavaScript validation and server 
side validation
  
  # Muli-page Registration Form
  multiRegistrationForm.title=Multi-page Registration Form
  multiRegistrationForm.description=multi-page example with client side JavaScript 
validation and server side validation
  
  # Type form
  typeForm.title=Type Form
  typeForm.description=Example validating some primitive numbers, a range on the 
integer field, a date, and a credit card number.
  typeForm.title.create=Type Form
  typeForm.byte.displayname=Byte Field
  typeForm.short.displayname=Short Field
  typeForm.integer.displayname=Integer Field
  typeForm.long.displayname=Long Field
  typeForm.float.displayname=Float Field
  typeForm.double.displayname=Double Field
  typeForm.date.displayname=Date Field
  typeForm.creditCard.displayname=Credit Card
  
  # JavaScript Type Form
  jsTypeForm.title=JavaScript Type Form
  jsTypeForm.description=with JavaScript Validation and Server Validation
  
  # Locale Form
  localeForm.fr=There are some differences on the Registration Form, JavaScript 
Registration Form, and Multi-page Registration form (see /WEB-INF/validation.xml).  On 
the Type Form and JavaScript Type Form the integer field should fall in a range of 
50-60 and the date field should have a format of 'dd.MM.yyyy'.
  localeForm.frCA=On the JavaScript Type Form the integer field should fall in a range 
of 100-200 and the date field should have a format of 'dd-MM-yyyy'.
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/ApplicationResources_fr.properties
  
  Index: ApplicationResources_fr.properties
  ===================================================================
  # Correct translations compliments of Regis Brochu
  # Some fields have been added after Regis Brochu 
  # translated the file and may have incorrect translation.
  button.cancel=Annuler
  button.confirm=Soumettre
  button.reset=Effacer
  button.save=Sauvegarder
  
  # Errors
  errors.footer=
  errors.header=<h3><font color="red">Erreur de Validation</font></h3>Vous devez 
corriger l'erreur(s) suivante avant de continuer :
  errors.ioException=Exception d'E/S durant le rendu des messages d'erreur: {0}
  error.database.missing=<li>La base de données des utilisateurs est manquante. 
Impossible de valider les privilèges de connexion
  errors.required={0} est obligatoire.
  errors.minlength=Le {0} ne peut pas être moins de {1} caractères.
  errors.maxlength=Le {0} ne peut pas être plus de {1} caractères.
  errors.invalid={0} est invalide.
  
  errors.byte=Le {0} doit être un nombre de type byte.
  errors.short=Le {0} doit être un nombre de type short.
  errors.integer=Le {0} doit être un nombre de type integer.
  errors.long=Le {0} doit être un nombre de type long.
  errors.float=Le {0} doit être un nombre de type float.
  errors.double=Le {0} doit être un nombre de type double.
  
  errors.date=Le {0} n'est pas une date.
  
  errors.range=Le {0} n'est pas dans l'intervalle {1} à {2}.
  
  errors.creditcard=Le {0} n'est pas un numéro de carte de crédit valide.
  
  errors.email=Le {0} est une adresse incorrecte de e-mail.
  
  # Index Page
  index.title=Struts Validator
  index.power=Actionné par Struts
  
  # Registration Form                                     
  registrationForm.title=Enregistrement
  registrationForm.title.create=Registre
  registrationForm.title.edit=Éditez l'information utilisateur
  registrationForm.firstname.displayname=Prénom
  registrationForm.lastname.displayname=Nom
  registrationForm.addr.displayname=Adresse
  registrationForm.city.displayname=Ville
  registrationForm.stateprov.displayname=État/Province
  registrationForm.zippostal.displayname=Code postal
  registrationForm.phone.displayname=Téléphone
  registrationForm.email.displayname=E-mail
  registrationForm.lastname.maskmsg=Le nom peut seulement être composé de lettres et 
de nombres, aucun espace.
  
  # Javascript Registration Form
  jsRegistrationForm.title=Enregistrement de JavaScript
  jsRegistrationForm.description=avec la validation de JavaScript de côté de client et 
la validation latérale de serveur 
  
  # Muli-page Registration Form
  multiRegistrationForm.title=De plusieurs pages Fiche
  multiRegistrationForm.description=exemple de plusieurs pages avec la validation du 
côté JavaScript de client et la validation latérale de serveur
  
  # Type form
  typeForm.title=Formulaire de type
  typeForm.description=Exemple validant quelques nombres primitifs, un intervalle sur 
la zone de nombre entier, une date, et un nombre de carte de crédit.
  typeForm.title.create=Créer le formulaire
  typeForm.byte.displayname=Champ Octet
  typeForm.short.displayname=Champ Short
  typeForm.integer.displayname=Champ Entier
  typeForm.long.displayname=Champ Long
  typeForm.float.displayname=Champ Float
  typeForm.double.displayname=Champ Double
  typeForm.date.displayname=Champ Date
  typeForm.creditCard.displayname=Champ Carte de crédit
  
  # JavaScript Type Form
  jsTypeForm.title=Formulaire de type de JavaScript
  jsTypeForm.description=avec la validation de JavaScript de côté de client et la 
validation latérale de serveur 
  
  # Locale Form
  localeForm.fr=Il y a quelques différences sur la fiche, la fiche de JavaScript, et 
la fiche de plusieurs pages (voient / WEB-INF/validation.xml). Sur la forme de forme 
de type et de type de JavaScript la zone de nombre entier devrait tomber dans un 
intervalle de 50-60 et la zone de date devrait avoir un format de ' dd.MM.yyyy '. 
  localeForm.frCA=Sur la forme de type de JavaScript la zone de nombre entier devrait 
tomber dans un intervalle de 100-200 et la zone de date devrait avoir un format de ' 
dd-MM-yyyy '. 
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/CityStateZip.java
  
  Index: CityStateZip.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.struts.webapp.validator;
  
  
  /**
   * Just used to provide an indexed properties example.
   *
   * @author David Wintefeldt
  */
  public class CityStateZip implements java.io.Serializable {
  
      private String sCity = null;
      private String sStateProv = null;
      private String[] sZipPostal = new String[3];
  
  
      public String getCity() {
         return sCity;  
      }
      
      public void setCity(String sCity) {
                this.sCity = sCity;
      }
  
      public String getStateProv() {
         return sStateProv;     
      }
      
      public void setStateProv(String sStateProv) {
                this.sStateProv = sStateProv;
      }
  
      public String getZipPostal(int index) {
         return sZipPostal[index];      
      }
      
      public void setZipPostal(int index, String value) {
                this.sZipPostal[index] = value;
      }
  
  }
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/LocaleAction.java
  
  Index: LocaleAction.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.struts.webapp.validator;
  
  import java.io.IOException;
  import java.util.Locale;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.commons.beanutils.PropertyUtils;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  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 
   * changes a locale based on request level parameters 
   * that are set (language &amp; country).
   *
   * @author David Wintefeldt
  */
  public final class LocaleAction extends Action {
  
      /**
       * Commons Logging instance.
      */
      private Log log = LogSource.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).
       * 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.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm 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
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a 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)
                PropertyUtils.getSimpleProperty(form, "language");
             country = (String)
                PropertyUtils.getSimpleProperty(form, "country");
          } catch (Exception 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");  
      }
  
  }
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/MultiRegistrationAction.java
  
  Index: MultiRegistrationAction.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.struts.webapp.validator;
  
  import java.io.IOException;
  import java.util.Locale;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionErrors;
  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 = LogSource.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).
       * 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.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm 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
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a 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");   
      }
  
      /**
       * Convenience method for removing the obsolete form bean.
       *
       * @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());
             }
         }
      }
  }
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/RegistrationAction.java
  
  Index: RegistrationAction.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.struts.webapp.validator;
  
  import java.io.IOException;
  import java.util.Locale;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  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 = LogSource.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).
       * 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.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm 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
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a 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"));
        }
  
        return mapping.findForward("success");
      }
  
      /**
       * Convenience method for removing the obsolete form bean.
       *
       * @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());
             }
         }
      }
  }
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/RegistrationForm.java
  
  Index: RegistrationForm.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.struts.webapp.validator;
  
  import java.io.Serializable;
  import javax.servlet.http.HttpServletRequest;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.validator.ValidatorForm;
  
  
  /**
   * Form bean for the user registration page.
   *
   * @author David Wintefeldt
  */
  public final class RegistrationForm extends ValidatorForm implements Serializable {
      private String action = null;
         
      private String sFirstName = null;
      private String sLastName = null;
      private String sAddr = null;
      private CityStateZip csz = new CityStateZip();
      private String sPhone = null;
      private String sEmail = null;
  
  
      public String getAction() {
        return action;
      }
  
      public void setAction(String action) {
          this.action = action;
      }
  
      public String getFirstName() {
         return sFirstName;     
      }
      
      public void setFirstName(String sFirstName) {
                this.sFirstName = sFirstName;
      }
      
      public String getLastName() {
         return sLastName;      
      }
      
      public void setLastName(String sLastName) {
                this.sLastName = sLastName;
      }
  
      public String getAddr() {
         return sAddr;  
      }
      
      public void setAddr(String sAddr) {
                this.sAddr = sAddr;
      }
  
      public CityStateZip getCityStateZip() {
         return csz;    
      }
      
      public void setCityStateZip(CityStateZip csz) {
                this.csz = csz;
      }
  
      public String getPhone() {
         return sPhone; 
      }
      
      public void setPhone(String sPhone) {
                this.sPhone = sPhone;
      }
  
      public String getEmail() {
         return sEmail; 
      }
      
      public void setEmail(String sEmail) {
                this.sEmail = sEmail;
      }
          
      /**
       * Reset all properties to their default values.
       *
       * @param mapping The mapping used to select this instance
       * @param request The servlet request we are processing
       */
      public void reset(ActionMapping mapping, HttpServletRequest request) {
         action = null;
         sFirstName = null;
         sLastName = null;
         sAddr = null;
         csz = new CityStateZip();
         sPhone = null;
         sEmail = null;
      }
  
  }
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/TypeAction.java
  
  Index: TypeAction.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.struts.webapp.validator;
  
  import java.io.IOException;
  import java.util.Locale;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  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 = LogSource.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).
       * 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.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm 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
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a 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);
  
            return (mapping.findForward("success"));
        }
  
        return mapping.findForward("success");  
      }
  
      /**
       * Convenience method for removing the obsolete form bean.
       *
       * @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());
             }
         }
      }
  }
  
  
  
  1.1                  
jakarta-struts/src/validator/org/apache/struts/webapp/validator/TypeForm.java
  
  Index: TypeForm.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.struts.webapp.validator;
  
  import java.io.Serializable;
  import javax.servlet.http.HttpServletRequest;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.validator.ValidatorForm;
  
  
  /**
   * Form bean for the user type page.
   *
   * @author David Wintefeldt
  */
  public final class TypeForm extends ValidatorForm implements Serializable {
      private String action = null;
         
      private String sByte = null;
      private String sShort = null;
      private String sInteger = null;
      private String sLong = null;
      private String sFloat = null;
      private String sDouble = null;
      private String sDate = null;
      private String sCreditCard = null;
  
      public String getAction() {
        return action;
      }
  
      public void setAction(String action) {
          this.action = action;
      }
  
      public String getByte() {
         return sByte;  
      }
      
      public void setByte(String sByte) {
                this.sByte = sByte;
      }
      
      public String getShort() {
         return sShort; 
      }
      
      public void setShort(String sShort) {
                this.sShort = sShort;
      }
  
      public String getInteger() {
         return sInteger;       
      }
      
      public void setInteger(String sInteger) {
                this.sInteger = sInteger;
      }
  
      public String getLong() {
         return sLong;  
      }
      
      public void setLong(String sLong) {
                this.sLong = sLong;
      }
  
      public String getFloat() {
         return sFloat; 
      }
      
      public void setFloat(String sFloat) {
                this.sFloat = sFloat;
      }
  
      public String getDouble() {
         return sDouble;        
      }
      
      public void setDouble(String sDouble) {
                this.sDouble = sDouble;
      }
  
      public String getDate() {
         return sDate;  
      }
      
      public void setDate(String sDate) {
                this.sDate = sDate;
      }
  
      public String getCreditCard() {
         return sCreditCard;    
      }
      
      public void setCreditCard(String sCreditCard) {
                this.sCreditCard = sCreditCard;
      }
          
      /**
       * Reset all properties to their default values.
       *
       * @param mapping The mapping used to select this instance
       * @param request The servlet request we are processing
       */
      public void reset(ActionMapping mapping, HttpServletRequest request) {
         action = null;
         sByte = null;
         sShort = null;
         sInteger = null;
         sLong = null;
         sFloat = null;
         sDouble = null;
         sDate = null;
         sCreditCard = null;
      }
  
  }
  
  
  

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

Reply via email to