Hi all,
I've noticed a place where a validation error is swallowed by my D2W app. I'm not sure where the expetion is getting lost because ERMDDeleteButton catches it, and calls parent().validationFailedWithException(e, e.object(), e.key()); (line 129 in ERMDDeleteButton) but the error never shows up in the UI. The UI makes it look as though the delete was successful, but it wasn't.
The situation is this: I'm deleting an EO, but the EO has a toMany relationship with a deny delete rule. I'm overriding mightDelete() to move the related objects to a different EO. If the _destination_ EO is invalid (missing required data) then it fails validation (as it should) and the EC can't be saved.
For example, let's say I have students that are registered for a math class. That class is canceled, so all the students associated with it should be moved to the next available math class. The problem is that the math class that the students are moved to doesn't have a start time, which is a mandatory attribute (as defined by the EOModel). So when the EC is saved, the new math class is what fails validation.
So, the delete fails validation, not because the deletion itself fails validation, but because EOs involved in the background business logic end up failing validation. EOF is doing the right thing and preventing the save, but the UI is never reporting the validation error nor reverting the EC, so the UI ends up showing that the related objects have been moved to the new EO and the original EO is gone. If you simply create a new session and fetch the objects again, you see that they are all back to the way they were before the attempted deletion.
In this situation, once I figured out that there was an effectively "swallowed" validation exception, and then _which_ object was causing it, I was able to fix my model so that this didn't throw the exception anymore and everything is working fine. BUT, this exception should be displayed in the UI.
Dave |