0

You must specify a number - Decimalbox validation message

asked 2015-07-22 11:06:32 +0800

vlknbkts gravatar image vlknbkts
1

Hello,

i have a question about the validation of Decimalbox. I create in my composer a decimalbox named dcmlbxAmount which accepts only amounts with a format of e.g. 239,00 42943,00

dcmlbxAmount.setId("dcmlbxAmount"); dcmlbxAmount.setSclass("dcmlbx-amount"); dcmlbxAmount.setFormat("#,##0.00########"); dcmlbxAmount.setRoundingMode(BigDecimal.ROUND_DOWN); dcmlbxAmount.setConstraint(new AmountValidator());

My AmountValidator checks some validation rules, but i get a validation message, i think a standard message, with "You must specify a number, rather than xxx.".

Problem at this point is the wrong message, it has to be "You must specify a amount, ...".

I think that this validation is executed before my AmountValidator#validate() method.

I would be very grateful for a useful solution.

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
0

answered 2015-07-23 21:20:08 +0800

Darksu gravatar image Darksu
1991 1 4

Hello vlknbkts,

I found a very interesting solution to a similar question at the following post:

http://stackoverflow.com/questions/10595985/removing-default-validation-messages-from-intbox-in-zkoss

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-07-24 13:35:02 +0800

vlknbkts gravatar image vlknbkts
1

Dear Darksu,

thank you for your anwser. I found that post, too. I override the coerceFromString() method of my subclass Amountbox too, but this method is never been called.

The standard validation message "You must specify..." have to override on client-side, so it needs to override the widget, i dont know.

I just need to change the original message, that's all.

Best regards.

link publish delete flag offensive edit
0

answered 2015-07-25 20:28:00 +0800

Darksu gravatar image Darksu
1991 1 4

Hello vlknbkts,

If i understand correctly you just want to change the message on the client side. You can do it as shown below:

<decimalbox constraint="no negative: your new message"/>

Best,

Darksu

link publish delete flag offensive edit
0

answered 2015-07-27 11:26:40 +0800

vlknbkts gravatar image vlknbkts
1

updated 2015-07-27 11:31:47 +0800

Hello Darksu,

exactly, thats what i want to do. But i create the decimalbox in my composer and set there a constraint-class as constraint.

dcmlbxAmount.setId("dcmlbxAmount"); dcmlbxAmount.setSclass("dcmlbx-amount"); dcmlbxAmount.setFormat("#,##0.00########"); dcmlbxAmount.setRoundingMode(BigDecimal.ROUND_DOWN); dcmlbxAmount.setConstraint(new AmountValidator()); <-- setting my constraint

But i get a standard validation message if i enter e.g. ",,..-". I try to debug the validation() method in my AmountValidator() which is my constraint-class, but the message when i enter ",,..-,." is showing before.

Best regards.

link publish delete flag offensive edit
0

answered 2015-08-03 18:06:19 +0800

vlknbkts gravatar image vlknbkts
1

Should i create a new component? This seems to be a validation message of ZK. It appears before the constraint validation.

Any ideas?

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2015-07-22 11:06:32 +0800

Seen: 38 times

Last updated: Aug 03 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More