Re: Validation exceptions
Re: Validation exceptions
- Subject: Re: Validation exceptions
- From: Ed Powell <email@hidden>
- Date: Sun, 5 Jan 2003 13:25:51 -0600 (CST)
Ok, this explained it, and helped me to remember what I was futzing with
before I took a couple weeks off from working on my project. :)
The saveChanges was being called... the problem was that it shouldn't have
been. In the component code, I have a boolean to indicate if
all validation passed. validateFailedWithException, I had it turn that
boolean false when it caught something... but in the action method
(submitRegistrationAction()), I had a line at the top arbitrarily changing
that boolean to true. And since the action code executes after the
validateFailedWithException code...
Now this leaves me with some design logic to figure out, but it solves
this particular maddening problem. :) Thanks for your help!
On Sun, 5 Jan 2003, Chuck Hill wrote:
> 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.