Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » How to get locale setting for client from scout session?
How to get locale setting for client from scout session? [message #1604173] Fri, 06 February 2015 17:40 Go to next message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
I have noticed that scout session will have a valid locale setting, however if I use any code that depends on default locale I will get the locale set on server. This holds for RAP server and Scout server components.

The thing is though that I know RAP client (in browser) for example has the correct locale set up so there should be a simple way to fetch and use that, right? I probably just missed something in manual but maybe someone can save me some time. Thanks.
Re: How to get locale setting for client from scout session? [message #1712653 is a reply to message #1604173] Tue, 27 October 2015 08:42 Go to previous messageGo to next message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
Figured it out - on the client to get client's locale: LocaleThreadLocal.get()

Is there a similar utility function on the server-side (to get client's locale)?

Re: How to get locale setting for client from scout session? [message #1712790 is a reply to message #1712653] Wed, 28 October 2015 09:32 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
NlsUtility.getDefaultLocale() should work both on server and client side. Its javadoc states:

Quote:
Only use this Locale resolver if the calling code is executed in both, server- and client side. On client side, use Locale.getDefault() whereas on server side use LocaleThreadLocal.get().
Re: How to get locale setting for client from scout session? [message #1712809 is a reply to message #1712790] Wed, 28 October 2015 11:41 Go to previous message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
I guess they mean "serverside" also on RAP server since Locale.getDefault() return's the JVM's locale.

This works LocaleThreadLocal.get() for RAP server and Scout server (I've just checked) so it seems to be what I need. I guess "client" here refers to rich client only and it makes sense from the technical standpoint. Thanks for the info about the other utility method!
Previous Topic:Properties in PageData (similar to FormData)
Next Topic:[Neon] Tell browser to open downloaded file in new browser window
Goto Forum:
  


Current Time: Thu Sep 26 02:53:53 GMT 2024

Powered by FUDForum. Page generated in 0.02706 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top