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)
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.NSKeyValueCoding$ValueAccessor$1.methodValue(NSKeyValueCoding.java:684)
at com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKeyValueCoding.java:1160)
at com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey(NSKeyValueCoding.java:1268)
at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1539)
at com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCoding.java:498)
at com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.valueForKeyPath(NSKeyValueCodingAdditions.java:212)
at com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1600)
at com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOKeyValueAssociation.java:46)
at com.webobjects.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton.java:70)
at com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:101)
at com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:110)
at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
at com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:101)
at com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:110)
at com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponentContent.java:31)
at com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:101)
at com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:110)
at com.webobjects.appserver._private.WOComponentContent.invokeAction(WOComponentContent.java:31)
at com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:101)
at com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:110)
at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
at com.webobjects.appserver._private.WOComponentReference.invokeAction(WOComponentReference.java:104)
at com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:101)
at com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:110)
at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
at com.webobjects.appserver._private.WOComponentReference.invokeAction(WOComponentReference.java:104)
at com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:101)
at com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:110)
at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
at com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedPage(WOComponentRequestHandler.java:196)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:287)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:322)
at com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:358)
at com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:432)
at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1306)
at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:613)