Return-Path: Delivered-To: apmail-pivot-user-archive@www.apache.org Received: (qmail 1767 invoked from network); 7 Mar 2011 00:50:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Mar 2011 00:50:28 -0000 Received: (qmail 59856 invoked by uid 500); 7 Mar 2011 00:50:28 -0000 Delivered-To: apmail-pivot-user-archive@pivot.apache.org Received: (qmail 59833 invoked by uid 500); 7 Mar 2011 00:50:28 -0000 Mailing-List: contact user-help@pivot.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@pivot.apache.org Delivered-To: mailing list user@pivot.apache.org Received: (qmail 59825 invoked by uid 99); 7 Mar 2011 00:50:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Mar 2011 00:50:28 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gk_brown@verizon.net designates 206.46.173.17 as permitted sender) Received: from [206.46.173.17] (HELO vms173017pub.verizon.net) (206.46.173.17) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Mar 2011 00:50:19 +0000 Received: from [192.168.1.15] ([unknown] [98.110.173.176]) by vms173017.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LHN00BCWWYYOXK0@vms173017.mailsrvcs.net> for user@pivot.apache.org; Sun, 06 Mar 2011 18:49:47 -0600 (CST) From: Greg Brown MIME-version: 1.0 (Apple Message framework v1082) Content-type: multipart/alternative; boundary=Apple-Mail-1--970760350 Subject: Re: TextInput and Validator issues Date: Sun, 06 Mar 2011 19:49:46 -0500 In-reply-to: To: user@pivot.apache.org References: <4D734FDA.7070702@free.fr> Message-id: <6ECB9157-E923-431D-8774-EEAA61FB7902@verizon.net> X-Mailer: Apple Mail (2.1082) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-1--970760350 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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 wrote: > I also tried StrictValidation=3D"true" and an intValidator that = accepts empty input by overriding isValid(): > public boolean isValid(String text) { > final ParsePosition pos =3D new ParsePosition(0); > Object obj =3D format.parseObject(text, pos); > if( obj =3D=3D null || text.length() =3D=3D 0) { > return true; > } >=20 > // the text is only valid is we successfully parsed ALL of it. = Don't want trailing bits of > // not-valid text. > return obj !=3D null && pos.getErrorIndex() =3D=3D -1 && = pos.getIndex() =3D=3D 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. >=20 > What else could I try ? >=20 >=20 > This seems to work for me. >=20 >=20 > public class XXXIntRangeValidator extends IntRangeValidator { > // Constructors... >=20 > @Override > public boolean isValid(String text) { > return (text.length() =3D=3D 0) || super.isValid(text);=20 > } > } --Apple-Mail-1--970760350 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii 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 <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); 
  }
}

--Apple-Mail-1--970760350--