NSNumberFormatter
NSNumberFormatter
- Subject: NSNumberFormatter
- From: Ingenieurbüro Birnfeld - Oliver Birnfeld <email@hidden>
- Date: Fri, 12 Jul 2013 14:21:23 +0200
- Organization: Ingenieurbüro Birnfeld
Hi,
I have a problem using NSNumberFormatter to validate the input of an
WOTextField. When e.g. setting formatter.setMinimum(5) and
formatter.setMaximum(20) then validationFailedWithException is called
for all values <0, >20, and 1-4 but _not_ for 0.
Here are some code snippets:
Constructor:
inputFormatter=new NSNumberFormatter("#");
inputFormatter.setMaximum(new BigDecimal(20));
inputFormatter.setMinimum(new BigDecimal(5));
public void validationFailedWithException(Throwable t, Object value,
String keyPath) {
if( keyPath.equals("value")) {
warningVisible=true;
}
validationError=true;
super.validationFailedWithException(t, value, keyPath);
}
public WOActionResults saveSettings() {
if( validationError) {
validationError=false;
return null;
}
return pageWithName("Main");
}
The html code looks like this:
<wo:textfield value="$value" formatter="$inputFormatter" />
Am I missing something?
Thanks!
Regards,
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