-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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.
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
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.
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.
Asked: 2015-07-22 11:06:32 +0800
Seen: 39 times
Last updated: Aug 03 '15