Re: Validation exceptions
Re: Validation exceptions
- Subject: Re: Validation exceptions
- From: Chuck Hill <email@hidden>
- Date: Sun, 05 Jan 2003 10:56:30 -0800
EOEditingContext.saveChanges. Ah. Now I understand.
validationFailedWithException is called when validation exceptions occur
during the takeValues phase. This does *not* happen when you call
saveChanges(). You need to wrap any call to saveChanges in a try...catch
block:
try {
session().defaultEditingContext().saveChanges();
}
catch (NSValidation$ValidationException e) {
// Handle validation faliures here.
// You can, if you want, do something like this
validationFailedWithException(e, e.object(), e.key());
}
What you probably want to do is to set a flag in
validationFailedWithException if there were any failures. If this flag is
set then don't call saveChanges(). Clear the flag after calling
super.appendToResponse.
Chuck
At 09:17 AM 05/01/2003 -0600, Ed Powell wrote:
>validateXxxx methods are all being called by WO. I don't have any direct
>calls to them.
>
>The following is the exception output. Line 63 in Users.java corresponds
>to the 'Check if what we have is null'-commented section. Linue 128 is
>where validateVerifyq creates the validatedVerifyq String.
>
>
>[2003-01-05 09:11:56 CST] <WorkerThread0> <WOApplication 'Syrinx'>:
>Exception occurred while handling request:
>com.webobjects.foundation.NSValidation$ValidationException: Verification
>question is required.
>[2003-01-05 09:11:56 CST] <WorkerThread0>
>com.webobjects.foundation.NSValidation$ValidationException: Verification
>question is required.
> at Users.masterStringValidator(Users.java:63)
> at Users.validateVerifyq(Users.java:128)
> at java.lang.reflect.Method.invoke(Native Method)
> at
>com.webobjects.foundation._NSReflectionUtilities._invokeMethodOnObject(_NSR
eflectionUtilities.java:383)
> at
>com.webobjects.foundation.NSValidation$_MethodBinding.validateValueOnObject
(NSValidation.java:455)
> at
>com.webobjects.foundation.NSValidation$DefaultImplementation._validateValue
ForKey(NSValidation.java:547)
> at
>com.webobjects.eocontrol.EOCustomObject.validateValueForKey(EOCustomObject.
java:917)
> at
>com.webobjects.eocontrol.EOCustomObject.validateForSave(EOCustomObject.java
:971)
> at
>com.webobjects.eocontrol.EOCustomObject.validateForInsert(EOCustomObject.ja
va:1015)
> at
>com.webobjects.eocontrol.EOEditingContext.validateTable(EOEditingContext.ja
va:1692)
> at
>com.webobjects.eocontrol.EOEditingContext.validateChangesForSave(EOEditingC
ontext.java:2362)
> at
>com.webobjects.eocontrol.EOEditingContext._prepareForPushChanges(EOEditingC
ontext.java:2554)
> at
>com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java
:2485)
> at
>RegistrationComponent.submitRegistrationAction(RegistrationComponent.java:94)
> at java.lang.reflect.Method.invoke(Native Method)
>
>
>On Sun, 5 Jan 2003, Tom Woteki wrote:
>
>> Are you calling validateVerifyq directly, or is WO calling it as part
>> of its form handling mechanism? validationFailed... will not be called
>> automatically in the former case.
>_______________________________________________
>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.
_______________________________________________
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.