You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/06/03 16:42:25 UTC

DO NOT REPLY [Bug 20449] New: - Define flag for validating current page only in multipage form

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20449>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20449

Define flag for validating current page only in multipage form

           Summary: Define flag for validating current page only in
                    multipage form
           Product: Commons
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Validator
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: bcantwel@us.ibm.com


In our current application, we have about 60 jsps.  The pages are set up in a 
wizard-like interface.  Depending on the data entered, a different path through 
the pages will be taken.  All data is captured in a single ActionForm, so we 
are using multipage validation.

Each page is numbered, but the pages are not numbered sequentially.  Depending 
on the data entered, a user on page 10 may be taken to page 8 or page 12.  In 
the current way that the multipage validation works, if there is a required 
field on page 8, but the user has been taken to page 12, it will generate an 
error requiring the field on page 8.

It would be nice if there were a flag that could be set that would allow the 
validate method to only validate the current page, rather than all pages less 
than or equal to the current page.  This would then need to be integrated into 
struts to set the flag.

Here is an example of how it could be done:

    public ValidatorResults validate() throws ValidatorException {
        ValidatorResults results = new ValidatorResults();
        Locale locale = null;

        if (hResources.containsKey(LOCALE_KEY)) {
            locale = (Locale) hResources.get(LOCALE_KEY);
        }
        hResources.put(VALIDATOR_KEY, this);

        if (locale == null) {
            locale = Locale.getDefault();
        }

        if (resources == null) {
            throw new ValidatorException("Resources not defined for Validator");
        }

        Form form = resources.get(locale, formName);
        if (form != null) {
            for (Iterator i = form.getFields().iterator(); i.hasNext();) {
                Field field = (Field) i.next();
/***********************************
 Check for the flag here 
************************************/
                if (validateCurrentPageOnly) {
                    if ((field.getPage() == page) && 
                        (field.getDepends() != null)) {
                        validateField(field, results);
                    }
                } else {
                    if ((field.getPage() <= page) && 
                        (field.getDepends() != null)) {
                        validateField(field, results);
                    }
                }
            }
        }
        return results;
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org