On Aug 4, 2011, at 2:45 PM, Michael Gargano wrote:

> it looks like the first time around the exception is thrown, swallowed by 
> something that then nulls that value

That would be a problem. I believe when you bind directly to an object, the 
WOComponent uses NSValidationUtilities to call validateValueForKey on the 
object.  If that throws an exception, it will call 
validationFailedWithException on itself... which it then promptly ignores.

http://webobjects.mdimension.com/javadoc/WebObjects/5.4/com/webobjects/appserver/WOComponent.html#validationFailedWithException(java.lang.Throwable,%20java.lang.Object,%20java.lang.String)

Your component should probably implement this method and pass the error up to 
the parent page, either by calling 
context().page().validationFailedWithException or by calling 
parent().validationFailedWithException and keep passing up the chain until you 
get to a component that wants to handle it properly.  You'll need to do this on 
ALL of your editing components, so you might want to use a superclass that 
implements validationFailedWithException and descend from it.

The parent page would then implement this method and use it to collect 
validation exceptions for display to the user.  Your subcomponent/delegate that 
is doing the save would want to check the collection point for error messages 
before attempting to saveChanges or you'll get the behavior you see now.

BTW, if you're using ERD2W, it does all this for you already (^_^)  Something 
like

EditMyEntity: ERXD2WInspect {
        pageConfiguration = "EditMyEntity";
        object = eo;
        displayKeys = "(name, shortDesc, longDesc)";
}


Ramsey

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

This email sent to [email protected]

Reply via email to