pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bartlett <cbartlet...@gmail.com>
Subject Re: TextInput and Validator issues
Date Sun, 06 Mar 2011 19:26:09 GMT
On 6 March 2011 16:11, anton dos santos <adsantos@free.fr> 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);
  }
}

Mime
View raw message