use of com.opensymphony.xwork2.ValidationAware in project qi4j-sdk by Qi4j.
the class ConstraintViolationInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext invocationContext = invocation.getInvocationContext();
ValueStack stack = invocationContext.getValueStack();
Object action = invocation.getAction();
if (action instanceof ValidationAware) {
ValidationAware va = (ValidationAware) action;
HashMap<Object, Object> propertyOverrides = new HashMap<Object, Object>();
for (Map.Entry<String, FieldConstraintViolations> fieldViolations : fieldConstraintViolations(invocationContext).entrySet()) {
addConstraintViolationFieldErrors(stack, va, fieldViolations.getKey(), fieldViolations.getValue());
propertyOverrides.put(fieldViolations.getKey(), getOverrideExpr(invocation, fieldViolations.getValue()));
}
// if there were some errors, put the original (fake) values in place right before the result
if (!propertyOverrides.isEmpty()) {
overrideActionValues(invocation, stack, propertyOverrides);
}
}
return invocation.invoke();
}
Aggregations