-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Validator Spring i18n
PostPosted: Wed Jun 26, 2013 9:51 am 
Newbie

Joined: Wed Jun 26, 2013 8:48 am
Posts: 1
Hello,

I using Spring 3.2.3 with Hibernate Validator 4.3.1.
We are using default Validators (like @NotEmpty) and own ValidatorClasses for our DTOs.

Until now Hibernate Validator could get the error messages from i18n (messages_propoerties) which we registered in the applicationContext.xml.
But now we want to valid an object which was send via AJAX (JSON format). We use this method signature in the controller:
Code:
@RequestMapping(value = "/ValidateMethod")
public @ResponseBody
   ArrayNode validateMethod(@Valid @RequestBody MyObjectClass myObject, BindingResult result) throws DatatypeConfigurationException {
        ...
}


The validation works but the messages will not be resolved. In the log I see:
Code:
Field error in object 'myObject' on field 'myField.myField ': rejected value ["ยง"];
codes [Pattern.myObject.myField.myField,Pattern.myField.myField ,Pattern.myField,Pattern.java.lang.String,Pattern];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [myObject.myField.myField,myField.myField];
arguments []; default message [myField.myField],[Ljavax.validation.constraints.Pattern$Flag;@9cd641,[0-9A-Za-z]{3,4}]; default message [must match "[0-9A-Za-z]{3,4}"]


And the validation returns then the message "must match "[0-9A-Za-z"".
In the property file I have the entry: Pattern.myObject.myField.myField=My validation message that should be displayed.

We do I not get this message? How I said, in non AJAX calls I use the same mechanism and there I get it.

Thanks for your time and help.

Greetings
hugi


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.