I was going to suggest something like this, though it seems like it might be better to make this configurable in the stock validator.
On Mar 6, 2011, at 2:26 PM, Chris Bartlett wrote: > On 6 March 2011 16:11, anton dos santos <[email protected]> wrote: > I also tried StrictValidation="true" and an intValidator that accepts empty > input by overriding isValid(): > public boolean isValid(String text) { > final ParsePosition pos = new ParsePosition(0); > Object obj = format.parseObject(text, pos); > if( obj == null || text.length() == 0) { > return true; > } > > // the text is only valid is we successfully parsed ALL of it. Don't > want trailing bits of > // not-valid text. > return obj != null && pos.getErrorIndex() == -1 && pos.getIndex() == > text.length(); > } > this works fine until user erases everything in the TextInput, from then on > use can enter any character, he is no longer limited to digits. > > What else could I try ? > > > This seems to work for me. > > > public class XXXIntRangeValidator extends IntRangeValidator { > // Constructors... > > @Override > public boolean isValid(String text) { > return (text.length() == 0) || super.isValid(text); > } > }
