Re: Validation Problem
Re: Validation Problem
- Subject: Re: Validation Problem
- From: Colin Clark <email@hidden>
- Date: Tue, 9 Dec 2003 17:10:12 -0500
Hi Jonathan,
In a simple case like this, I'd be tempted just make the ivar private
and use get and set methods. In the mutator, you can check for null and
modify it as you see fit. Something like this:
public void setMyInt(int value) {
if (value == null)
myInt = 0;
else
myInt = value;
}
If you want your users to legitimately supply null values, you'll need
to declare your number as an Integer type, rather than using the int
primitive.
You can also see WOComponent's validateValueForKey() method to handle
component-level key validation, but again, the value you're validating
has to be an object, not a primitive.
Colin
On Tuesday, December 9, 2003, at 03:08 PM, Jonathan Fleming wrote:
Hi mmalc and all,
Practically all the validation I've ever done has been on EO's, but
now I need to validate an int bound to a WOTextField which is only an
iVar not an EO. I want to validate for a null value. What would be the
best way to do this as I am getting this error at the moment:
Error: java.lang.IllegalArgumentException: [ takeValueForKey()]:
Failed to assign null to key 'qty.
Reason: [<ProductItem name: ProductItem subcomponents: null >
takeValueForKey()]: Failed to assign null to key 'qty.
Kind regards
Jonathan
_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection
http://www.msn.co.uk/specials/btbroadband
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
---
Colin Clark
Dynamic Web/Database Developer
Resource Centre for Academic Technology,
University of Toronto
(416) 946-7592 / email@hidden
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.