Re: NSNumberFormatter
Re: NSNumberFormatter
- Subject: Re: NSNumberFormatter
- From: Christoph Wick <email@hidden>
- Date: Mon, 15 Jul 2013 12:06:17 +0200
Hi Oliver,
use the "validateKey" mechanism (where "Key" is the name of property, e.g. myNumber)
public Object validateMyNumber(Object aValue) throws NSValidation.ValidationException {
// 1. cast aValue to int (or whatever you need
// 2. write check method, e.g. SOMETHINGWRONGWITH_aValue
// throw exception, if aValue is not what you want it to be
if (SOMETHINGWRONGWITH_aValue) {
throw new NSValidation.ValidationException(aValue+" is not allowed for property 'MyNumber');
}
}
This method will be called by WO automatically before the settermethod setMyNumber is called.
Or you overwrite "validateForSave" or "validateForUpdate" in your entity's class (which should be a subclass of EOCustomObject).
For more basic information see:
https://developer.apple.com/legacy/library/#documentation/WebObjects/Enterprise_Objects/BusinessLogic/BusinessLogic.html#//apple_ref/doc/uid/TP30001011-CH204-DontLinkElementID_12
or the documentation of NSValidation
http://wocommunity.org/documents/javadoc/WebObjects/5.4.2/com/webobjects/foundation/NSValidation.html
or the documentation of EOCustomObject
http://wocommunity.org/documents/javadoc/WebObjects/5.4.2/com/webobjects/eocontrol/EOCustomObject.html#validateForUpdate()
Hope, this helps ...
C.U.CW
--
Christoph Wick - Diplom Informatiker, Managing Director
i4innovation GmbH, Professor-Neu-Allee 39, 53225 Bonn, Germany
T +49 2 28 28 62 97 93
M +49 1 51 22 65 78 90
F +49 2 28 28 62 97 99
M email@hidden
W www.i4innovation.de
Geschäftsführer: Thomas Heep, Christoph Wick
Sitz der Gesellschaft: Bonn | Amtsgericht Bonn HRB 18548 | USt-IdNr.: DE276502600
On 15.07.2013, at 11:21, Ingenieurbüro Birnfeld - Oliver Birnfeld <email@hidden> wrote:
>>> inputFormatter=new NSNumberFormatter("0");
> The same result as with "#". I think, I have to write my own validator. Any newbie hints for that task?
>
> Thanks!
>
> Oliver
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden