commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30955] New: - Locale validation doesn't validate all fields (improper form processing)
Date Tue, 31 Aug 2004 09:30:20 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30955>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30955

Locale validation doesn't validate all fields (improper form processing)

           Summary: Locale validation doesn't validate all fields (improper
                    form processing)
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Validator
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: nacho@visual-ma.com


Say we have the following formSet definition:

<!DOCTYPE form-validation PUBLIC
     "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 
1.1//EN"
     "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd">
     
<form-validation>
   <global>
      <validator name="required"
                 classname="org.apache.commons.validator.TestValidator"
                 method="validateRequired"
                 
methodParams="java.lang.Object,org.apache.commons.validator.Field"
                 msg=""/>
   </global>
   <formset>
      <form name="nameForm">
         <field property="firstName" depends="required">
             <arg key="nameForm.firstname.displayname"/>
         </field>    
         <field property="lastName" depends="required">
             <arg key="nameForm.lastname.displayname"/>
         </field>
      </form>
   </formset>   
   <formset language="en" country="US" variant="TEST1">
      <form name="nameForm">
         <field property="middleName" depends="required">
             <arg key="nameForm.lastname.displayname"/>
         </field>
      </form>
   </formset>   

</form-validation>

You would expect that when validating with locale en_US_TEST1 middleName would 
be mandatory, but it isn't because in ValidatorResources.processForms() while 
adding the default fields to the current form, we are not adding the fields 
from the form itself! 

Now there is a decision to make and that is what is the preferred order for the 
merged form (merged because we are adding the fields from the default formset). 
I'd say to put first the default formset's fields, but I think it would be nice 
to be able to specify its order (for javascript mainly). 

IMO, this bug is very related to #16920 because it is a locale issue and it has 
to do with the way forms are processed. I would propose to have a locale 
hierarchy: If we are using the formset with locale "en_US_TEST1", this formset 
should include the fields from "en_US", "en" and the default formSet (of course 
iff they haven't been overriden).

I've made a patch which solves this issues. All the tests are passing fine and 
the new one I created for checking this bug also.

If this is done properly, the "extends" attribute from Form gains added 
functionality. Right now, form extension is only looking in the formSet it 
belongs which includes its forms + defaultForms. We could have a extension 
syntax definition for this making it possible to extend "en.US.formName" or 
something like this (I am not sure if this would be useful though if we make a 
proper use of the locale hierarchy I talked about). So the ideal scenario would 
be to have a huge default form set, small language aware formsets, smaller 
country aware formsets and so on. I beleive the philosophy of the validator 
should go this way (I think it was in the first place).

Tell me what you all think and I'll submit a patch if necessary.

Nacho G. Mac Dowell

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


Mime
View raw message