Here's the problem:
I have a custom validator registered in faces-config.xml and applied for an input field backed with Double attribute. The problem is that when I enter some value considered non-double I get a validation and error which I've never wrote and my actual validator is never entered. Actually even if don't set any validation it still gives me the default validation error if I set some non-Double value. I see my sysout messages only and only when the value is a Double (at this step there's is no point in any validation already). The reasons of my discontents are: 1) I need to override validation message. 2) I need a specific currency validation not just of Double type. Any ideas what I'm doing wrong?
Custom validator class:
Is there any way to override the default validation?
I am completely sure I have no extra parameters or global validators registered anywhere in my app. Nor in beans neither in faces-config. I also have many other fields where I use the same pattern and all works just fine, the problem is with Double values only. I hate this voodoo magic stuff...
Thanks in advance
Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?
There is no such thing as a "default validator". It would help if you listed the actual message.
Also, I'm a little confused as to what you mean, since the only case where you'd get a double into this arrangement would be if the setter for "montosolicitado" takes a double as its argument.
However, in that case, the convertor would be offended, since you are permitting inputs with characters such as currency symbols and grouping separators that are not permitted when specifying double (or float) constants. If you can't use the text in the expression "new Double(text)" without getting a conversion exception in basic Java, you can't use the text in this context either, since that's the conversion method used.
To permit formatted currency, you'd need a custom convertor as well as the validator. One that knew how to ignore the currency symbols and group separators.
On the other hand, I seem to recall that the JSF standard converter toolset includes a currency-format option on the number converter or something like that.
An IDE is no substitute for an Intelligent Developer.
The message is: form_solicitud:monto_solicitado: 'asd' must be a number consisting of one or more digits.
The thing here is that I do not use error.properties or similar generic validation overrides, just custom validators set implicitly to be able to denote every field failing by its form description and not ugly limited id.
As for the converter I didn't have time to come to this part yet but I will. Still the input should be validated before it's converted or the convertor will fail. The actual problem is that the validation used in my case never gets to my custom validator and thats what worries me. And it's even worse - the field is always validated even if I leave it with the value attribute only. I don't believe I can't just set a field for a Double bean property without it being always validated. I am not a beginner in JSF and I though I control who gets validated and who doesn't...
One interesting fact btw. Some time ago I tried EJB bean validation using annotations from hibernate validation lib. It didn't work as I expected and I deleted all the changes as well as the lib, cleaned the project and redeployed it. And that's why I call it freakin magic: the validation from the EJB was there... Well, it's difficult to surprise me, so I completely cleaned and rebuilt the project, reinstalled the server from scratch, rebooted the pc (since RAM and cache act like a damn parallel universe sometimes) launched the app, and what do you think - the bean validation was still there. The field I was experimenting with was this and very same one I'm having problems right now...
A few more days with this thing and I will dedicate the rest of my life to the ancient maya gods.
That is truly interesting. Without actually experimenting, I'm suspecting there's several factors. You have 'required="true"'. Since you're coding in Spanish and the error is in English that does tend to imply that the framework is taking over, and although it goes against what I "know" about JSF, it's possible that there is a "pre-validator" being applied by the "required" processor.
I think I just used up my quote-mark allotment for the week.
Just for giggles, try removing the "required" attribute and message and see if that changes things. Also look into the currency option of the JSF standard number converter.
And please avoid handling sharp objects made of obsidian.