-->
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.  [ 8 posts ] 
Author Message
 Post subject: validator messages swing client i18n
PostPosted: Wed Aug 29, 2007 3:16 am 
Newbie

Joined: Wed Aug 29, 2007 2:53 am
Posts: 9
I try to use the classvalidator in our project with a server and a swing client.

My problem comes with i18n of the messages. Messages from the server are in the language of the default locale of the server.
A solution could be a getMessage(string language) method on InvalidValue.
The languages could be restricted by overwriting the ValidatorMessages.properties or providing a custom bundle, throw away the unused.

Any ideas?

Bart

An elegant solution to translate the fieldName is also welcome, but that's treated in another thread.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 5:12 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You can implement a MessageInterpolator that can deal with that, I think

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 1:47 am 
Newbie

Joined: Wed Aug 29, 2007 2:53 am
Posts: 9
A MessageInterpolator returns 1 String, the message. I could construct a long string with all languages in, and parse it when needed but that's not very robust.
If I could provide my own InvalidValue (with x messages) and intervene in some way in the validation (like MessageInterpolator), I could construct the Invalidvalue that is returned by the validator.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 5:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I was thinking that MessageInterpolator could retrieve the right Locale (for example set to a threadlocal by your application), to build the right message right away.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 03, 2007 6:36 am 
Newbie

Joined: Wed Aug 29, 2007 2:53 am
Posts: 9
In the project , we're using Spring's HttpInvoker for the remote calls. The language of the client can be switched as the user wants, it's not stored in the DB.
To know the language at the server means that the language should be added to each call.

For now , in this client, we validate twice, once before the call (thus in the client locale) and on the server before saving.
It's a solution for this project.

Apparently there's no other way to solve it then by the messageinterpolator. I hope future releases bring more possibilities (and a way to translate the fieldname).

thanks for the reactions.

Bart


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 8:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
But the messageInterpolator solution work and does not seem to be that hard to implement, is it?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 05, 2007 2:16 am 
Newbie

Joined: Wed Aug 29, 2007 2:53 am
Posts: 9
It works, if the locale is added to each call to the server.
But in that case I could set it as default and there would be no need for a MessageInterpolator.
My question was how to do it without knowing the language in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 05, 2007 10:15 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If the MessageInterpolator read the Locale from a threadlocal variable that is set by your code right before validating, you have what you want

_________________
Emmanuel


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

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.