You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Timmy <ts...@x76.eu> on 2016/05/13 06:49:32 UTC

User (session) specific number formatting which overrides Locale

Hello!
I understand I can support different locale for users using the 
I18nInterceptor and the request_locale parameter.

Is there a similar solution for "Number Formatting"?

A number of users have expressed they wish to see 4 decimals instead of 
only 2, and I can not find a good solution for this that only works for 
this subset of users.


One idea I had was to set the number-format in a session, and then use 
it (if it exist) for number formatting. But despite experiments, this 
does not seem to work :/


Anyone have an idea what I can do?

Thank you.

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


Re: User (session) specific number formatting which overrides Locale

Posted by Andreas <an...@muha.net>.
Thank you Christoph,
that sounds like something I could try out.

I was on the verge on implementing my on s.text-tag...

Regards


On 2016-05-13 16:41, Christoph Nenning wrote:
>> Hello!
>> I understand I can support different locale for users using the 
>> I18nInterceptor and the request_locale parameter.
>>
>> Is there a similar solution for "Number Formatting"?
>>
>> A number of users have expressed they wish to see 4 decimals instead of 
>> only 2, and I can not find a good solution for this that only works for 
>> this subset of users.
>>
>>
>> One idea I had was to set the number-format in a session, and then use 
>> it (if it exist) for number formatting. But despite experiments, this 
>> does not seem to work :/
>>
>>
>> Anyone have an idea what I can do?
>>
> Hi,
>
>
> in our apps we use user locale specific formatters for a lot of things 
> including numbers, dates, times, currency, ...
>
>
> Usually we have an java object on ValueStack (can be in a base class for 
> all actions or in a dedicated class placed on stack by an interceptor) 
> which provides methods in the form:
>
> formatDate(Date)
> formatTime(Date)
> formatInteger(Long)
> formatDouble(Double)
> ...
>
> Those methods can pickup the locale from several places, including 
> HttpSession.
> They are invoked from JSPs via OGNL expressions.
>
> Hope this helps,
> Christoph
>
> This Email was scanned by Sophos Anti Virus
>


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


Re: User (session) specific number formatting which overrides Locale

Posted by Christoph Nenning <Ch...@lex-com.net>.
> Hello!
> I understand I can support different locale for users using the 
> I18nInterceptor and the request_locale parameter.
> 
> Is there a similar solution for "Number Formatting"?
> 
> A number of users have expressed they wish to see 4 decimals instead of 
> only 2, and I can not find a good solution for this that only works for 
> this subset of users.
> 
> 
> One idea I had was to set the number-format in a session, and then use 
> it (if it exist) for number formatting. But despite experiments, this 
> does not seem to work :/
> 
> 
> Anyone have an idea what I can do?
> 

Hi,


in our apps we use user locale specific formatters for a lot of things 
including numbers, dates, times, currency, ...


Usually we have an java object on ValueStack (can be in a base class for 
all actions or in a dedicated class placed on stack by an interceptor) 
which provides methods in the form:

formatDate(Date)
formatTime(Date)
formatInteger(Long)
formatDouble(Double)
...

Those methods can pickup the locale from several places, including 
HttpSession.
They are invoked from JSPs via OGNL expressions.

Hope this helps,
Christoph

This Email was scanned by Sophos Anti Virus