PDA

View Full Version : Bug in TextField.validateValue ???



mburkhart
2 Jan 2012, 11:39 AM
Applies to Ext GWT up to 2.2.5

In case of an empty string and blanks allowed, TextField.validateValue will invoke Field.clearValidate. However, this means, that even if called via Field.isValid, validation errors will be cleared. IMHO that's a nasty side effect of a method which returns a boolean result (and causing me some headache). I am absolutely fine with Field.validate doing this, but then that one is implying completly different semantics ("do something" instead of "check something").

So before going and hacking the code (it really causes problems at this end), I'd just like to know whether there actually might be a reason for this ... and possibly a bugfix (I checked 2.2.5 though and nope).

Thanks a lot (and tanks anyway for this fantastic library)!

Colin Alworth
3 Jan 2012, 4:07 PM
Unless I am misunderstanding, this is only a bug if you expect there to be validation error messages for an otherwise valid value. If you want to set an error message such that it cannot be cleared by validating the field, use the forceInvalid(String) method.

Yes, the semantics are a little off, but the behavior is there to make sure the value returned is consistent with the ui.

mburkhart
9 Jan 2012, 7:42 AM
Thanks for the answer. It's fair enough. Problem is, that some code I inherited sets error messages based on complex server side validation logic -- and I cannot use forceInvalid for other complex reasons (yea ... I know ... but hacking the GXT code was the simplest solution right now).