Hi Ted,

if your „problem“ is related to a specific textfield then you can add a 
numberformat binding to that WOTextField. This should give you a validation 
exception if your user entered a non-number value.

jw


> Am 08.11.2014 um 06:04 schrieb Theodore Petrosky <[email protected]>:
> 
> I’ve never written a validator before. Is this okay:
> 
>       public String validateJobNumber(String value) throws 
> ValidationException {
> 
>               value = value.trim();
> 
>               boolean isNumber = true;
>               endOfLoop:
>               for (int i = 0; i < value.length(); i++) {
> 
>                       if (Character.isDigit(value.charAt(i))) {
>                               isNumber = true;
>                       } else {
>                               isNumber = false;
>                               break endOfLoop;
>                       }
>               }
> 
>               if (!isNumber) {
>                       throw new ValidationException("There can be only 
> numbers in the Job Number field! (value was " + value +")");
>               }
>               return value;
>       }
> 
> It works, but is there some error that I am making that will bite me later?
> 
> Ted
> 
> On Nov 7, 2014, at 8:04 PM, Ramsey Gurley <[email protected]> wrote:
> 
>> If you always only want to allow number characters, then implement a 
>> validateKey() method for that key on your EO. This is easier.
>> 
>> public String validateJobNumber(String value)
>> 
>> Alternately, you can provide a custom component that does the validation at 
>> the component level. For example, you have a bunch of old jobs that already 
>> have strings outside your defined range and you cannot validate at the EO. 
>> This prevents new jobs from being entered with job numbers like “00-103A” or 
>> something, but also won’t throw errors on old jobs unless the user tries to 
>> edit them using the component.
>> 
>> 
>> On Nov 7, 2014, at 5:51 PM, Theodore Petrosky <[email protected]> wrote:
>> 
>>> How would you limit the characters typed into a WOTextField in a D2W app?
>>> 
>>> I need a text field for a Job Number. It’s not really a number per se. 
>>> Although I want to limit the characters typed to the number keys. So 
>>> basically ascii 48 to 57 inclusive.
>>> 
>>> Ted
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com
>>> 
>>> This email sent to [email protected]
>> 
> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/jw%40oyosys.com
> 
> This email sent to [email protected]

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to