[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
label formatmask  XML
Forum Index -> Development
Author Message
bthalheim

Power User

Joined: 05/04/2012 11:45:24
Messages: 72
Offline

Hi,

my produkt owner wants me to display a BigDecimal with two digits after a comma. This would be the right way to display amounts of money:
- 17,55
- 17,50
- 17,00

I have already done the following:
- format="bigdecimal"
- formatmask="dec2"

For the examples mentioned above, this should work.
Unfortunately, there now happens something like:
- 35.000,00

How can I make sure that a comma (,) will be always used between the Euros and the Cents and nowhere else anything else?

Regards,

Björn
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5538
Offline

Hi,

all bigdecimal, float, double formats internall use...

Code:
             NumberFormat nf = NumberFormat.getNumberInstance();
 


The behavior with adding some thousands-separator is coming from the default implementation.

But, if you may pass an own format in FORMATMASK as well, which is then passed in the client in the following way:

Code:
                     DecimalFormat df = new DecimalFormat(i_formatmask);
 


Regards, Björn

Björn Müller, CaptainCasa GmbH
dstrigel

Power User

Joined: 09/12/2010 09:23:42
Messages: 69
Offline

Hi,

try
formatmask="0.00"

Regards
Daniel
bthalheim

Power User

Joined: 05/04/2012 11:45:24
Messages: 72
Offline

Hi,

using "0.00" works, but unfortunately, it depends on the JVM default locale to decide wheter . or , is used as a decimal separator.

Is there any way in CaptainCasa to do what looks in the code like this:
Code:
 DecimalFormatSymbols dfs = new DecimalFormatSymbols();
 dfs.setDecimalSeparator(',');
 decimalFormat.setDecimalFormatSymbols(dfs);
 System.out.println(decimalFormat.format(1202.22));
 //Output: 1202,22
 


Regards,

Björn
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5538
Offline

Hi,

well, all the client formatting of labels and formatted fields (using FORMAT and FORMATMASK) has the purpose to follow some localization aspects - so that American users see "100,000.00" whereas German users see "100.000,00". ;-)

If you really want to do "brute force formatting" - again; ;-)... - then I would propose to just use a normal String as output and do the formatting on server side.

Regards, Björn

Björn Müller, CaptainCasa GmbH
bthalheim

Power User

Joined: 05/04/2012 11:45:24
Messages: 72
Offline

Hi,

Björn, are you sure that german users see german formatting and english users see english formatting?

I would say, the user, whatever language he or she has chosen, sees the number formatting of the language in which the server JVM runs ...

Regards,

Björn
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5538
Offline

Hi,

please note: there are two areas of I18N - the client and the server.
Both can be fine-controlled to your needs - and both are technically independent from one another.

The client localization can be set via the user (configuration icon) or can be set by using the CLIENTCONFIG Element. If not explicitly defined then the client will always use the localization of the client's VM.

In the Developers' Guide there is a documentation on this...

Regards, Björn

Björn Müller, CaptainCasa GmbH
bthalheim

Power User

Joined: 05/04/2012 11:45:24
Messages: 72
Offline

Hi,

Björn, you are exactly right.
Since it was OK for our project to show the user decimal seperators according to his or her language,
- format="bigdecimal" and
- formatmask="0.00"
do exactly the job and nothing needs to be done in the UI Code.
Thank you very much, this job is done now.

Regards,

Björn
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team