You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2006/04/08 02:06:51 UTC

DO NOT REPLY [Bug 39251] New: - validator's locale

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=39251>.
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=39251

           Summary: validator's locale
           Product: Struts
           Version: 1.2.9
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Apps
        AssignedTo: dev@struts.apache.org
        ReportedBy: wshao@perpetual.com


I am trying to write a form with zip/postal code, which needs to be validated. 
The validation is based on country.  So if it's a US zip code, the form should
be "ddddd-dddd" or "ddddd".  If it's a Canada postal code, the form should be
"a1b 2c3".  And if it's another country's postal code, we will allow any kind of
input.

So according to struts manual, the formset with no locale specifications is set
to be the default locale.  So I created 3 validation xml files:
/WEB-INF/validation_en_US.xml, /WEB-INF/validation_en_CA.xml,
/WEB-INF/validation.xml.

Here is what I found: when I set en_CA as my country, Canadian's postal zip will
be correctly validated.  When I set any other country as my country, the
validation rule will be either from validation_en_US.xml or validation.xml,
depending on which validation xml file is being put in the struts-config.xml
first.  So I debugged code of ValidatorPlugIn's code and figured that the 2
formsets (default and en_US) are both considered as value of the key "en_US" in
the formset FashHashMap.

And another thing I found for the validation xml files is that as much as
country information is the only thing I will need for the zip code validation. 
I just have to enter the language attribute in the formset tag.  So instead of
using <formset country="CA">, I will have to specify the language for this for
the formset.  This is kind of awkward.  Because it's not necessary a user
viewing our website is set his/her lauguage to be the same as the formset
setting, although he/she could be in US/Canada.  It looks like struts has a much
better message search rule than validation search rule.

I am pretty sure I can fix all this by overriding the ValidatorPlugin class.  I
just want to try my luck to see if the developers of the struts considering this
as a bug or I actually mis-configged anything.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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