1
- /* Copyright 2010 the original author or authors.
1
+ /* Copyright 2010-2012 the original author or authors.
2
2
*
3
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
4
* you may not use this file except in compliance with the License.
@@ -152,9 +152,11 @@ class JQueryValidationUiTagLib {
152
152
String errorClass = attrs. errorClass?: config. errorClass?: " error"
153
153
String validClass = attrs. validClass?: config. validClass?: " valid"
154
154
def onsubmit = attrs. onsubmit ? Boolean . valueOf(attrs. onsubmit) : config. get(" onsubmit" , true )
155
- def submitHandler = attrs. remove(" submitHandler" )
155
+ def submitHandler = attrs. remove(" submitHandler" )
156
156
def renderErrorsOnTop = attrs. renderErrorsOnTop ? Boolean . valueOf(attrs. renderErrorsOnTop) : config. get(" renderErrorsOnTop" , true )
157
157
String renderErrorsOptions
158
+ Locale locale = RCU . getLocale(request)
159
+
158
160
if (! forClass) {
159
161
throwTagError(" ${ TAG_ERROR_PREFIX} Tag missing required attribute [for]" )
160
162
}
@@ -247,10 +249,10 @@ rules: {
247
249
constrainedPropertiesEntries << childConstrainedPropertiesEntry
248
250
}
249
251
250
- out << createJavaScriptConstraints(constrainedPropertiesEntries)
252
+ out << createJavaScriptConstraints(constrainedPropertiesEntries, locale )
251
253
out << " },\n " // end rules
252
254
out << " messages: {\n "
253
- out << createJavaScriptMessages(constrainedPropertiesEntries)
255
+ out << createJavaScriptMessages(constrainedPropertiesEntries, locale )
254
256
out << " }\n " // end messages
255
257
out << " });\n "
256
258
out << " });\n "
@@ -274,7 +276,7 @@ rules: {
274
276
return constraintsMap
275
277
}
276
278
277
- private String createJavaScriptConstraints (List constrainedPropertiesEntries ) {
279
+ private String createJavaScriptConstraints (List constrainedPropertiesEntries , Locale locale ) {
278
280
String javaScriptConstraints = " "
279
281
def constraintsMap
280
282
String javaScriptConstraint
@@ -305,7 +307,7 @@ rules: {
305
307
case Float :
306
308
case Double :
307
309
case BigDecimal :
308
- javaScriptConstraintCode = " \t number : true"
310
+ javaScriptConstraintCode = " \t ${ (locale.country == 'br' || locale.country == 'de')?'numberDE':'number' } : true"
309
311
break
310
312
}
311
313
@@ -442,7 +444,7 @@ rules: {
442
444
return constraintNames
443
445
}
444
446
445
- private String createJavaScriptMessages (List constrainedPropertiesEntries ) {
447
+ private String createJavaScriptMessages (List constrainedPropertiesEntries , Locale locale ) {
446
448
def constraintsMap
447
449
def args = []
448
450
String javaScriptMessages = " "
@@ -473,7 +475,10 @@ rules: {
473
475
case Float :
474
476
case Double :
475
477
case BigDecimal :
476
- javaScriptMessageCode = " \t number: '${ getTypeMismatchMessage(constrainedPropertiesEntry.validatableClass, constrainedProperty.propertyType, constrainedPropertiesEntry.namespace, constrainedProperty.propertyName)} '"
478
+ if (locale. country == ' br' || locale. country == ' de' )
479
+ javaScriptMessageCode = " \t numberDE: '${ getTypeMismatchMessage(constrainedPropertiesEntry.validatableClass, constrainedProperty.propertyType, constrainedPropertiesEntry.namespace, constrainedProperty.propertyName)} '"
480
+ else
481
+ javaScriptMessageCode = " \t number: '${ getTypeMismatchMessage(constrainedPropertiesEntry.validatableClass, constrainedProperty.propertyType, constrainedPropertiesEntry.namespace, constrainedProperty.propertyName)} '"
477
482
break
478
483
}
479
484
0 commit comments