Crud. I tried to append the stack trace to this message, but it got kicked back to me from the list for being too long. Chuck should have received it, though.
On Jun 7, 2007, at 2:04 PM, Chuck Hill wrote:
On Jun 7, 2007, at 1:43 PM, Janine Sisk wrote:
I'm totally stumped by this. Here's the scenario:
The user chooses a file to upload that we can't handle. They hit the submit button. My saveChanges method runs,
Does not! :-P At least not exactly like that. Here is what really happens:
takeValuesFromRequest runs, calls validateValueForKey on the EO for each form value. If the value is valid, it then calls setValueForKey. If the value is not valid, it calls validationFailedWithException.
When that is all finished, it starts on invokeAction. That is when your saveChanges runs.
I see validateValueForKey, but nothing about takeValuesFromRequest.
which runs the built-in one, which validates all the attributes in my model.
Yes, a second time. But the failure during takeValues... has already happened and you should check for it not _not_ call ec. saveChanges(). Just refresh the page and show the validation error messages(s).
It seems like something is amiss/amok. I only seem to be going into validateBigImage once, and that's after I've called ec.saveChanges. Plus, before I call ec.saveChanges I check for an error that happened previously and there isn't one.
My validateBigImage method runs, which checks the image and sees that it's the wrong kind, so it throws an NSValidation.ValidationException. This would, one would think, cause validationFailedWithException to run, but it doesn't.
It should, during the takeValuesFromRequest phase. Calling that is something that WOAssocation does. WOAssociaton is an object created from one binding in the WOD file. More than you wanted to know, eh?
Why not, and/or how do I figure out what's going on? I figured out how to use the debugger, set a breakpoint on the line where I throw my exception, and followed it the rest of the way through. Other than verifying that it never goes in to validationFailedWithException, which I already knew, it didn't tell me much.
It _should_ be getting to that method. Look at there it is getting throw. Look up (down) in the stack trace. Do you see takeValuesFromRequest? Anything about a WOAssociation?
Nope, neither.
Is the method signature correct?
public void validationFailedWithException(Throwable t, Object value, String keyPath) {
It should be correct, you're the one who told me to use it. :)
at java.lang.Thread.dumpStack(Thread.java:1176)
at com.nhlpm.eo.DisplayBoard.validateBigImage(DisplayBoard.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation._NSReflectionUtilities._invokeMethodOnObject(_NSReflectionUtilities.java:383)
at com.webobjects.foundation.NSValidation$_MethodBinding.validateValueOnObject(NSValidation.java:615)
at com.webobjects.foundation.NSValidation$DefaultImplementation._validateValueForKey(NSValidation.java:705)
at com.webobjects.eocontrol.EOCustomObject.validateValueForKey(EOCustomObject.java:1341)
at com.webobjects.eocontrol.EOCustomObject.validateForSave(EOCustomObject.java:1411)
at com.webobjects.eocontrol.EOCustomObject.validateForInsert(EOCustomObject.java:1473)
at com.webobjects.eocontrol.EOEditingContext.validateTable(EOEditingContext.java:2249)
at com.webobjects.eocontrol.EOEditingContext.validateChangesForSave(EOEditingContext.java:3029)
at com.webobjects.eocontrol.EOEditingContext._prepareForPushChanges(EOEditingContext.java:3283)
at com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3213)
at com.nhlpm.pages.AddEdit.saveChanges(AddEdit.java:53)
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.