Search in sources :

Example 1 with AppendingValidatorContext

use of com.opensymphony.xwork2.validator.validators.VisitorFieldValidator.AppendingValidatorContext in project struts by apache.

the class VisitorFieldValidator method validateObject.

private void validateObject(String fieldName, Object o, String visitorContext) throws ValidationException {
    ValueStack stack = ActionContext.getContext().getValueStack();
    stack.push(o);
    ValidatorContext validatorContext;
    if (appendPrefix) {
        ValidatorContext parent = getValidatorContext();
        validatorContext = new AppendingValidatorContext(parent, createTextProvider(o, parent), fieldName, getMessage(o));
    } else {
        ValidatorContext parent = getValidatorContext();
        CompositeTextProvider textProvider = createTextProvider(o, parent);
        validatorContext = new DelegatingValidatorContext(parent, textProvider, parent);
    }
    actionValidatorManager.validate(o, visitorContext, validatorContext);
    stack.pop();
}
Also used : DelegatingValidatorContext(com.opensymphony.xwork2.validator.DelegatingValidatorContext) ValueStack(com.opensymphony.xwork2.util.ValueStack) DelegatingValidatorContext(com.opensymphony.xwork2.validator.DelegatingValidatorContext) ValidatorContext(com.opensymphony.xwork2.validator.ValidatorContext) CompositeTextProvider(com.opensymphony.xwork2.CompositeTextProvider)

Example 2 with AppendingValidatorContext

use of com.opensymphony.xwork2.validator.validators.VisitorFieldValidator.AppendingValidatorContext in project struts by apache.

the class AppendingValidatorContextTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    action = container.inject(VisitorValidatorTestAction.class);
    TextProviderFactory tpf = container.getInstance(TextProviderFactory.class);
    ValidatorContext vc1 = new DelegatingValidatorContext(action, tpf);
    VisitorFieldValidator.AppendingValidatorContext vc2 = new AppendingValidatorContext(vc1, createTextProvider(action, vc1), FIRST_NAME, "");
    validatorContext = new AppendingValidatorContext(vc2, createTextProvider(action, vc2), SECOND_NAME, "");
}
Also used : TextProviderFactory(com.opensymphony.xwork2.TextProviderFactory) VisitorValidatorTestAction(com.opensymphony.xwork2.validator.VisitorValidatorTestAction) DelegatingValidatorContext(com.opensymphony.xwork2.validator.DelegatingValidatorContext) DelegatingValidatorContext(com.opensymphony.xwork2.validator.DelegatingValidatorContext) AppendingValidatorContext(com.opensymphony.xwork2.validator.validators.VisitorFieldValidator.AppendingValidatorContext) ValidatorContext(com.opensymphony.xwork2.validator.ValidatorContext) AppendingValidatorContext(com.opensymphony.xwork2.validator.validators.VisitorFieldValidator.AppendingValidatorContext) AppendingValidatorContext(com.opensymphony.xwork2.validator.validators.VisitorFieldValidator.AppendingValidatorContext)

Aggregations

DelegatingValidatorContext (com.opensymphony.xwork2.validator.DelegatingValidatorContext)2 ValidatorContext (com.opensymphony.xwork2.validator.ValidatorContext)2 CompositeTextProvider (com.opensymphony.xwork2.CompositeTextProvider)1 TextProviderFactory (com.opensymphony.xwork2.TextProviderFactory)1 ValueStack (com.opensymphony.xwork2.util.ValueStack)1 VisitorValidatorTestAction (com.opensymphony.xwork2.validator.VisitorValidatorTestAction)1 AppendingValidatorContext (com.opensymphony.xwork2.validator.validators.VisitorFieldValidator.AppendingValidatorContext)1