dgraham     2003/03/04 18:53:15

  Modified:    src/share/org/apache/struts/validator
                        DynaValidatorActionForm.java DynaValidatorForm.java
  Log:
  Set page variable from dyna map before validating.  PR #17299.
  
  Revision  Changes    Path
  1.8       +19 -16    
jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java
  
  Index: DynaValidatorActionForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DynaValidatorActionForm.java      18 Oct 2002 01:35:02 -0000      1.7
  +++ DynaValidatorActionForm.java      5 Mar 2003 02:53:15 -0000       1.8
  @@ -7,7 +7,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
  @@ -62,6 +62,8 @@
   package org.apache.struts.validator;
   
   import java.io.Serializable;
  +import java.util.Map;
  +
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
   
  @@ -88,7 +90,6 @@
    * @version $Revision$ $Date$
    * @since Struts 1.1
    */
  -
   public class DynaValidatorActionForm extends DynaValidatorForm implements DynaBean, 
Serializable {
   
       /**
  @@ -103,20 +104,22 @@
        * <code>null</code> or an <code>ActionErrors</code> object with no
        * recorded error messages.
        *
  -     * @param mapping The mapping used to select this instance
  -     * @param request The servlet request we are processing
  -     * @return  ActionErrors containing validation errors.
  +     * @param mapping The mapping used to select this instance.
  +     * @param request The servlet request we are processing.
  +     * @return ActionErrors containing validation errors.
        */
  -    public ActionErrors validate(ActionMapping mapping,
  -                                 HttpServletRequest request) {
  -
  +    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
{
  +        // set the page variable before validating
  +        Map props = this.getMap();
  +        if (props.containsKey("page")) {
  +            this.page = ((Integer) props.get("page")).intValue();
  +        }
  +        
           ServletContext application = getServlet().getServletContext();
           ActionErrors errors = new ActionErrors();
   
  -        Validator validator = Resources.initValidator(mapping.getPath(),
  -                             this,
  -                             application, request,
  -                             errors, page);
  +        Validator validator =
  +            Resources.initValidator(mapping.getPath(), this, application, request, 
errors, page);
   
           try {
               validatorResults = validator.validate();
  
  
  
  1.8       +31 -30    
jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java
  
  Index: DynaValidatorForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DynaValidatorForm.java    8 Nov 2002 19:46:35 -0000       1.7
  +++ DynaValidatorForm.java    5 Mar 2003 02:53:15 -0000       1.8
  @@ -7,7 +7,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
  @@ -89,7 +89,6 @@
    * @since Struts 1.1
    * @see org.apache.struts.action.ActionForm
    */
  -
   public class DynaValidatorForm extends DynaActionForm implements DynaBean, 
Serializable {
   
       /**
  @@ -124,35 +123,37 @@
           this.page = page;
       }
   
  -   /**
  -     * Validate the properties that have been set from this HTTP request,
  -     * and return an <code>ActionErrors</code> object that encapsulates any
  -     * validation errors that have been found.  If no errors are found, return
  -     * <code>null</code> or an <code>ActionErrors</code> object with no
  -     * recorded error messages.
  -     *
  -     * @param mapping The mapping used to select this instance
  -     * @param request The servlet request we are processing
  -    * @return  <code>ActionErrors</code> object that encapsulates any  validation 
errors
  -     */
  -    public ActionErrors validate(ActionMapping mapping,
  -                                 HttpServletRequest request) {
  -
  -       ServletContext application = getServlet().getServletContext();
  +    /**
  +      * Validate the properties that have been set from this HTTP request,
  +      * and return an <code>ActionErrors</code> object that encapsulates any
  +      * validation errors that have been found.  If no errors are found, return
  +      * <code>null</code> or an <code>ActionErrors</code> object with no
  +      * recorded error messages.
  +      *
  +      * @param mapping The mapping used to select this instance.
  +      * @param request The servlet request we are processing.
  +      * @return <code>ActionErrors</code> object that encapsulates any validation 
errors.
  +      */
  +    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
{
  +        // set the page variable before validating
  +        Map props = this.getMap();
  +        if (props.containsKey("page")) {
  +            this.page = ((Integer) props.get("page")).intValue();
  +        }
  +    
  +        ServletContext application = getServlet().getServletContext();
           ActionErrors errors = new ActionErrors();
  -
  -       Validator validator = Resources.initValidator(mapping.getAttribute(),
  -                             this,
  -                             application, request,
  -                             errors, page);
  -
  -       try {
  +    
  +        Validator validator =
  +            Resources.initValidator(mapping.getAttribute(), this, application, 
request, errors, page);
  +    
  +        try {
               validatorResults = validator.validate();
           } catch (ValidatorException e) {
               log.error(e.getMessage(), e);
           }
  -
  -       return errors;
  +    
  +        return errors;
       }
   
      /**
  
  
  

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

Reply via email to