Examples of DelegatingValidatorContext


Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        if (appendPrefix) {
            validatorContext = new AppendingValidatorContext(getValidatorContext(), o, fieldName, getMessage(o));
        } else {
            ValidatorContext parent = getValidatorContext();
            validatorContext = new DelegatingValidatorContext(parent, DelegatingValidatorContext.makeTextProvider(o, parent), parent);
        }

        actionValidatorManager.validate(o, visitorContext, validatorContext);
        stack.pop();
    }
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        addValidationErrors(violations.toArray(new ConstraintViolation[violations.size()]), action, valueStack, null);
    }

  private void addValidationErrors(ConstraintViolation[] violations, Object action, ValueStack valueStack, String parentFieldname) {
    if (violations != null) {
            ValidatorContext validatorContext = new DelegatingValidatorContext(action);
            for (ConstraintViolation violation : violations) {
                //translate message
                String key = violation.getMessage();

                String message = key;
                // push context variable into stack, to allow use ${max}, ${min} etc in error messages
                valueStack.push(violation.getMessageVariables());
                //push the validator into the stack
                valueStack.push(violation.getContext());
                try {
                    message = validatorContext.getText(key);
                } finally {
                    valueStack.pop();
                    valueStack.pop();
                }

                if (isActionError(violation)) {
                    if (LOG.isDebugEnabled()) {
                  LOG.debug("Adding action error '#0'", message);
                    }
                    validatorContext.addActionError(message);
                } else {
                    ValidationError validationError = buildValidationError(violation, message);

                    // build field name
                    String fieldName = validationError.getFieldName();
                    if (parentFieldname != null) {
                      fieldName = parentFieldname + "." + fieldName;
                    }

                    if (LOG.isDebugEnabled()) {
                  LOG.debug("Adding field error [#0] with message '#1'", fieldName, validationError.getMessage());
                    }
                    validatorContext.addFieldError(fieldName, validationError.getMessage());

                    // don't add "model." prefix to fields of model in model driven action
                    if ((action instanceof ModelDriven) && "model".equals(fieldName)) {
                      fieldName = null;
                    }
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        addValidationErrors(violations.toArray(new ConstraintViolation[violations.size()]), action, valueStack, null);
    }

  private void addValidationErrors(ConstraintViolation[] violations, Object action, ValueStack valueStack, String parentFieldname) {
    if (violations != null) {
            ValidatorContext validatorContext = new DelegatingValidatorContext(action);
            for (ConstraintViolation violation : violations) {
                //translate message
                String key = violation.getMessage();

                String message = key;
                // push context variable into stack, to allow use ${max}, ${min} etc in error messages
                valueStack.push(violation.getMessageVariables());
                //push the validator into the stack
                valueStack.push(violation.getContext());
                try {
                    message = validatorContext.getText(key);
                } finally {
                    valueStack.pop();
                    valueStack.pop();
                }

                if (isActionError(violation)) {
                    if (LOG.isDebugEnabled()) {
                  LOG.debug("Adding action error '#0'", message);
                    }
                    validatorContext.addActionError(message);
                } else {
                    ValidationError validationError = buildValidationError(violation, message);

                    // build field name
                    String fieldName = validationError.getFieldName();
                    if (parentFieldname != null) {
                      fieldName = parentFieldname + "." + fieldName;
                    }

                    if (LOG.isDebugEnabled()) {
                  LOG.debug("Adding field error [#0] with message '#1'", fieldName, validationError.getMessage());
                    }
                    validatorContext.addFieldError(fieldName, validationError.getMessage());

                    // don't add "model." prefix to fields of model in model driven action
                    if ((action instanceof ModelDriven) && "model".equals(fieldName)) {
                      fieldName = null;
                    }
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        if (messageKey != null) {
            if ((defaultMessage == null) || ("".equals(defaultMessage.trim()))) {
                defaultMessage = messageKey;
            }
            if (validatorContext == null) {
                validatorContext = new DelegatingValidatorContext(object);
            }
            List<Object> parsedMessageParameters = null;
            if (messageParameters != null) {
                parsedMessageParameters = new ArrayList<Object>();
                for (String messageParameter : messageParameters) {
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        if (messageKey != null) {
            if ((defaultMessage == null) || ("".equals(defaultMessage.trim()))) {
                defaultMessage = messageKey;
            }
            if (validatorContext == null) {
                validatorContext = new DelegatingValidatorContext(object);
            }
            List<Object> parsedMessageParameters = null;
            if (messageParameters != null) {
                parsedMessageParameters = new ArrayList<Object>();
                for (String messageParameter : messageParameters) {
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        addValidationErrors(violations.toArray(new ConstraintViolation[0]), action, valueStack, null);
    }

  private void addValidationErrors(ConstraintViolation[] violations, Object action, ValueStack valueStack, String parentFieldname) {
    if (violations != null) {
            ValidatorContext validatorContext = new DelegatingValidatorContext(action);
            for (ConstraintViolation violation : violations) {
                //translate message
                String key = violation.getMessage();

                //push the validator into the stack
                valueStack.push(violation.getContext());
                String message = key;
                try {
                    message = validatorContext.getText(key);
                } finally {
                    valueStack.pop();
                }

                if (isActionError(violation)) {
                  LOG.debug("Adding action error '#0'", message);
                    validatorContext.addActionError(message);
                } else {
                    ValidationError validationError = buildValidationError(violation, message);

                    // build field name
                    String fieldName = validationError.getFieldName();
                    if (parentFieldname != null) {
                      fieldName = parentFieldname + "." + fieldName;
                    }

                    LOG.debug("Adding field error [#0] with message '#1'", fieldName, validationError.getMessage());
                    validatorContext.addFieldError(fieldName, validationError.getMessage());

                    // don't add "model." prefix to fields of model in model driven action
                    if ((action instanceof ModelDriven) && "model".equals(fieldName)) {
                      fieldName = null;
                    }
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        if (messageKey != null) {
            if ((defaultMessage == null) || ("".equals(defaultMessage.trim()))) {
                defaultMessage = messageKey;
            }
            if (validatorContext == null) {
                validatorContext = new DelegatingValidatorContext(object);
            }
            List<Object> parsedMessageParameters = null;
            if (messageParameters != null) {
                parsedMessageParameters = new ArrayList<Object>();
                for (String messageParameter : messageParameters) {
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        addValidationErrors(violations.toArray(new ConstraintViolation[0]), action, valueStack, null);
    }

  private void addValidationErrors(ConstraintViolation[] violations, Object action, ValueStack valueStack, String parentFieldname) {
    if (violations != null) {
            ValidatorContext validatorContext = new DelegatingValidatorContext(action);
            for (ConstraintViolation violation : violations) {
                //translate message
                String key = violation.getMessage();

                //push the validator into the stack
                valueStack.push(violation.getContext());
                String message = key;
                try {
                    message = validatorContext.getText(key);
                } finally {
                    valueStack.pop();
                }

                if (isActionError(violation)) {
                  LOG.debug("Adding action error '#0'", message);
                    validatorContext.addActionError(message);
                } else {
                    ValidationError validationError = buildValidationError(violation, message);

                    // build field name
                    String fieldName = validationError.getFieldName();
                    if (parentFieldname != null) {
                      fieldName = parentFieldname + "." + fieldName;
                    }

                    LOG.debug("Adding field error [#0] with message '#1'", fieldName, validationError.getMessage());
                    validatorContext.addFieldError(fieldName, validationError.getMessage());

                    // don't add "model." prefix to fields of model in model driven action
                    if ((action instanceof ModelDriven) && "model".equals(fieldName)) {
                      fieldName = null;
                    }
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        if (messageKey != null) {
            if ((defaultMessage == null) || ("".equals(defaultMessage.trim()))) {
                defaultMessage = messageKey;
            }
            if (validatorContext == null) {
                validatorContext = new DelegatingValidatorContext(object);
            }
            List<Object> parsedMessageParameters = null;
            if (messageParameters != null) {
                parsedMessageParameters = new ArrayList<Object>();
                for (String messageParameter : messageParameters) {
View Full Code Here

Examples of com.opensymphony.xwork2.validator.DelegatingValidatorContext

        if (appendPrefix) {
            validatorContext = new AppendingValidatorContext(getValidatorContext(), o, fieldName, getMessage(o));
        } else {
            ValidatorContext parent = getValidatorContext();
            validatorContext = new DelegatingValidatorContext(parent, DelegatingValidatorContext.makeTextProvider(o, parent), parent);
        }

        actionValidatorManager.validate(o, visitorContext, validatorContext);
        stack.pop();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.