I hope I am understanding you correctly Pascal, so……..

Form values are pushed in takeValueFromRequest using the 
validateTakeValueForKey( … )  …… only then will your WOComponent 
validationFailedWithException be called.

So BEFORE you call ec.saveChanges, you need to check if you have validation 
errors and then return your page with validation errors displayed.

If you don't, then ec.saveChanges will call validateForSave, which will AGAIN 
call validateKey on all your EO attributes and throw NSValidation.Exception. 
ec.saveChanges will NOT call your component's validationFailedWithException.

HTH, Kieran


On Oct 4, 2011, at 8:23 AM, Pascal Robert wrote:

> I guess working with REST and calendars made my brain to forget how to do 
> things with stateful components... I need to trap validation exceptions when 
> required attributes are missing and ec.saveChanges() is called, so in my 
> superclass for my components, I did:
> 
>   public void validationFailedWithException(Throwable exception, Object 
> value, String keyPath) {
>     super.validationFailedWithException(exception, value, keyPath);
>     ((Session)session()).addError(exception.getMessage());
>   }
> 
> And I made a component to display the errors if session.errors() is not 
> empty. Problem is: when saveChanges is called, I'm getting the generic 
> exceptions page instead of my page with the ErrorsDisplay component. With the 
> debugger, I do see that I go into validationFailedWithException, so I'm a bit 
> lost of why I'm getting the generic exceptions page.
> 
> What I'm doing wrong?
> 
> _______________________________________________
> 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/kelleherk%40gmail.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:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to