errorKeyOrder.addObject(d2wContext().displayNameForProperty()); errorMessages.setObjectForKey(erv.getMessage(), d2wContext().displayNameForProperty());   keyPathsWithValidationExceptions.addObject(erv.propertyKey()); if (erv.eoObject() != null && erv.propertyKey() != null && shouldSetFailedValidationValue()) { try { erv.eoObject().takeValueForKeyPath(value, erv.propertyKey()); } catch(NSKeyValueCoding.UnknownKeyException  ex) {   } catch(NoSuchElementException  ex) {   } }
if ( d2wContext().propertyKey() != null ) { errorKeyOrder.addObject(d2wContext().displayNameForProperty()); errorMessages.setObjectForKey(erv.getMessage(), d2wContext().displayNameForProperty());   keyPathsWithValidationExceptions.addObject(erv.propertyKey()); if (erv.eoObject() != null && erv.propertyKey() != null && shouldSetFailedValidationValue()) { try { erv.eoObject().takeValueForKeyPath(value, erv.propertyKey()); } catch(NSKeyValueCoding.UnknownKeyException  ex) {   } catch(NoSuchElementException  ex) {   } } }
    public void validationFailedWithException(Throwable e, Object value, String keyPath) {        if (validationLog.isDebugEnabled()) {        	validationLog.debug("Validation failed with exception: " + e + " value: " + value + " keyPath: " + keyPath);        }        if (shouldCollectValidationExceptions()) {            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 (keyPath.equals("value")) {                	keyPath = ""+d2wContext().valueForKey("propertyKey");                }                erv.setContext(d2wContext());                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                keyPathsWithValidationExceptions.addObject(erv.propertyKey());                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                	}                }               } else {                _temp.removeAllObjects();                ERXValidation.validationFailedWithException(e, value, keyPath, _temp, propertyKey(), ERXLocalizer.currentLocalizer(), d2wContext().entity(), shouldSetFailedValidationValue());                errorKeyOrder.addObjectsFromArray(_temp.allKeys());                errorMessages.addEntriesFromDictionary(_temp);            }            d2wContext().takeValueForKey(errorMessages, Keys.errorMessages);            if (keyPath != null) {                // this is set when you have multiple keys failing                // your keyPath should look like "foo,bar.baz"                if(keyPath.indexOf(",") > 0) {                    keyPathsWithValidationExceptions.addObjectsFromArray(NSArray.componentsSeparatedByString(keyPath, ","));                } else {                    keyPathsWithValidationExceptions.addObject(keyPath);                }            }        } else if (parent() != null && shouldPropagateExceptions()) {            parent().validationFailedWithException(e, value, keyPath);        }    }