commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc Schipperheyn" <m.schipperh...@tfe.nl>
Subject Validator internationalization: constants not applied
Date Sat, 23 Apr 2005 20:27:33 GMT
Hi,

I have a struts application that needs to serve multilingual websites for
multiple countries. Every country has the same language parameters but
varying validation-constants for things like zipcodes and mobile phones. I
use commons validator 1.1.4 and struts 1.2.6

When the validation is applied, the locale specific validation (_NL) isn't
applied but the default. When I step through the code I see in
ValidatorResources getForm that the hFormSets has two keys: "nl_NL" and
"_NL". Under nl_NL the default formset is stored and under _NL the _NL
formset. I don't understand this. There is no "nl_NL" key defined in my
validation files. 

Is this a bug or a configuration issue? How do I get around it?

Struts-config.xml
    <!-- ========== Controller Configuration ============ -->
    <controller>
    	<set-property property="processorClass"
value="nl.aaa.process.SecureRequestProcessor" />
    </controller>
    
    <!-- ========== Message Resources Definitions =========== -->
    <message-resources parameter="nl.aaa.ApplicationResources" null="false"
/>

		
    <!-- ========== Plug Ins Configuration =================================
-->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml,/WEB-INF/validat
ion-constants_NL.xml" />
    </plug-in>

In my secure request processor I (for testing purposes) set my Locale
	protected void processLocale(HttpServletRequest req,
HttpServletResponse res) {
		req.getSession().setAttribute(Globals.LOCALE_KEY, new
Locale("nl","NL"));
	}

Validation-constants_NL.xml
<form-validation>
<global>
	 <constant>
		<constant-name>mobile</constant-name>
		<constant-value>^06[-| ]?[0-9]{8}$</constant-value>
	</constant>  
	<constant>
 		<constant-name>zipcode</constant-name>
		<constant-value>^[0-9]{4} [a-zA-Z]{2}$</constant-value>
	</constant>  
</global>

<formset country="NL">
	<form name="EditSubscriberForm">
		<field property="zipcode"
            depends="required,mask">
            <msg name="mask" key="baseprofileform.errors.zipcodeformat"/>
            <arg0 name="required" key="baseprofileform.zipcode"/>
            <arg0 name="mask" key="baseprofileform.zipcode"/>
            <var>
            	<var-name>mask</var-name>
            	<var-value>${zipcode}</var-value>
            </var>
        </field>
	</form>

Validation.xml
		<form name="EditSubscriberForm">
			<field property="zipcode"
                depends="required">
                <arg0 name="required" key="baseprofileform.zipcode"/>
	        </field>
	        <field property="provinceID"
                depends="validwhen">
                <arg0 key="subscriptionform.province"/>
	    		<var>
	    			<var-name>test</var-name>
	    			<var-value>(*this* != 0)</var-value>
	    		</var>
	        </field>
		</form>

Kind regards,
Marc Schipperheyn



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


Mime
View raw message