if(validationDelegate() != null) {
validationDelegate().validationFailedWithException(e, value, keyPath);
return;
}
if (e instanceof ERXValidationException) {
ERXValidationException erv = (ERXValidationException) e;
// DT: if we are using the ERXValidation dictionary in the
// EOModel to define validation rules AND
// if we are using keyPaths like person.firstname instead of
// firstname because we have something like:
// user <<-> person and are editing an user instance then
// without this fix here the ERD2WPropertyKey
// would not recognize that 'his' value failed.
if ("value".equals(keyPath)) {
keyPath = "" + d2wContext().propertyKey();
}
erv.setContext(d2wContext());
if (d2wContext().propertyKey() != null) {
if(!errorKeyOrder.containsObject(d2wContext().displayNameForProperty())) {
errorKeyOrder.addObject(d2wContext().displayNameForProperty());
}
errorMessages.setObjectForKey(erv.getMessage(), d2wContext().displayNameForProperty());
// DT: the propertyKey from the validationException is
// important because keyPath might only be
// saveChangesExceptionKey
// which is not enough
String key = erv.propertyKey();
if (key == null) {
key = d2wContext().propertyKey();
}
keyPathsWithValidationExceptions.addObject(key);
if (erv.eoObject() != null && erv.propertyKey() != null && shouldSetFailedValidationValue()) {
try {
erv.eoObject().takeValueForKeyPath(value, erv.propertyKey());
} catch (NSKeyValueCoding.UnknownKeyException ex) {
// AK: as we could have custom components that have
// non-existant keys
// we of course can't push a value, so we discard
// the resulting exception
} catch (NoSuchElementException ex) {
// AK: as we could have custom components that have
// non-existant keys
// we of course can't push a value, so we discard
// the resulting exception
}
}
}
if(("saveChangesExceptionKey".equals(keyPath) || "queryExceptionKey".equals(keyPath)) && erv.propertyKey() != null) {
// AK: this is for combined keys like company,taxIdentifier
keyPathsWithValidationExceptions.addObjectsFromArray(NSArray.componentsSeparatedByString( erv.propertyKey(), ","));
}
} else {
_temp.removeAllObjects();
ERXValidation.validationFailedWithException(e, value, keyPath, _temp, propertyKey(), ERXLocalizer.currentLocalizer(), d2wContext().entity(),
shouldSetFailedValidationValue());