Example usage for org.springframework.validation Errors pushNestedPath

List of usage examples for org.springframework.validation Errors pushNestedPath

Introduction

In this page you can find the example usage for org.springframework.validation Errors pushNestedPath.

Prototype

void pushNestedPath(String subPath);

Source Link

Document

Push the given sub path onto the nested path stack.

Usage

From source file:com.springsource.hq.plugin.tcserver.serverconfig.ValidationUtils.java

/**
 * Performs validation of the given <code>Collection</code> of <code>Validator</code> instances. Each
 * <code>Validator</code> is treated as a self-validating domain object, i.e. the following is called upon each
 * <code>Validator</code>: <code>validator.validate(validator, errors)</code>. The given <code>identifier</code> is
 * used when pushing the path on the given <code>errors</code>, e.g. an identifier of 'foo' will result in
 * <code>foo[i]</code> being pushed, where i is the index of the validator in the given collection. The given
 * <code>errors</code> will be used to record any errors that are found.
 * // w w w .  jav  a2  s  .  c om
 * @see Validator#validate(Object, Errors)
 * 
 * @param selfValidatingItems The self-validating items to validate
 * @param identifier The identifier
 * @param errors Passed to each validator and to be used to record any errors
 */
public static void validateCollection(Collection<? extends Validator> selfValidatingItems, String identifier,
        Errors errors) {
    Iterator<? extends Validator> iterator = selfValidatingItems.iterator();
    int index = 0;
    while (iterator.hasNext()) {
        errors.pushNestedPath(String.format("%s[%d]", identifier, index++));
        Validator selfValidating = iterator.next();
        selfValidating.validate(selfValidating, errors);
        errors.popNestedPath();
    }
}

From source file:it.f2informatica.core.validator.AbstractValidator.java

protected void invokeValidator(Validator validator, Object target, String nestedPath, Errors errors) {
    try {/*w ww  .j  a  v a 2s . c o  m*/
        errors.pushNestedPath(nestedPath);
        ValidationUtils.invokeValidator(validator, target, errors);
    } finally {
        errors.popNestedPath();
    }
}

From source file:csns.web.validator.ItemValidator.java

@Override
public void validate(Object target, Errors errors) {
    Item item = (Item) target;/*from w  w w.ja  v  a2  s .  c om*/

    errors.pushNestedPath("resource");
    ValidationUtils.invokeValidator(resourceValidator, item.getResource(), errors);
    errors.popNestedPath();
}

From source file:csns.web.validator.SurveyResponseValidator.java

@Override
public void validate(Object target, Errors errors) {
    SurveyResponse response = (SurveyResponse) target;
    errors.pushNestedPath("answerSheet");
    ValidationUtils.invokeValidator(answerSheetValidator, response.getAnswerSheet(), errors);
}

From source file:org.openmrs.module.metadatasharing.model.validator.SubscriptionHeaderValidator.java

/**
 * @see org.springframework.validation.Validator#validate(java.lang.Object,
 *      org.springframework.validation.Errors)
 * @should reject invalid package header
 * @should reject empty content URI/*  w  ww  . j  a v a2s  .c o m*/
 */
@Override
public void validate(Object target, Errors errors) {
    SubscriptionHeader header = (SubscriptionHeader) target;
    errors.pushNestedPath("packageHeader");
    ValidationUtils.invokeValidator(packageValidator, header.getPackageHeader(), errors);
    errors.popNestedPath();

    ValidationUtils.rejectIfEmpty(errors, "contentUri",
            "metadatasharing.error.subscriptionHeader.contentUri.empty", "The contentUri cannot be empty");
}

From source file:com.create.validation.ListValidator.java

private void validate(List<?> targets, int index, Errors errors) {
    final String nestedPath = nestedPathConverter.getNestedPath(index);
    errors.pushNestedPath(nestedPath);
    final Object target = targets.get(index);
    invokeValidator(validator, target, errors);
    errors.popNestedPath();/*from   w w  w  . j  a va  2  s  .  c o m*/
}

From source file:com.springsource.hq.plugin.tcserver.serverconfig.resources.jdbc.DbcpDataSource.java

public void validate(Object target, Errors errors) {
    DbcpDataSource dataSource = (DbcpDataSource) target;
    errors.pushNestedPath("general");
    dataSource.getGeneral().validate(dataSource.getGeneral(), errors);
    errors.popNestedPath();/*w ww.j av  a2  s  .  c  o m*/
    errors.pushNestedPath("connection");
    dataSource.getConnection().validate(dataSource.getConnection(), errors);
    errors.popNestedPath();
    errors.pushNestedPath("connectionPool");
    dataSource.getConnectionPool().validate(dataSource.getConnectionPool(), errors);
    errors.popNestedPath();
}

From source file:com.springsource.hq.plugin.tcserver.serverconfig.configuration.jvm.Environment.java

public void validate(Object target, Errors errors) {
    Environment environment = (Environment) target;
    errors.pushNestedPath("jvmOptions");
    environment.getJvmOptions().validate(environment.getJvmOptions(), errors);
    errors.popNestedPath();/*from  ww  w  .j a va  2 s . c om*/
}

From source file:com.springsource.hq.plugin.tcserver.serverconfig.resources.jdbc.TomcatDataSource.java

public void validate(Object target, Errors errors) {
    TomcatDataSource dataSource = (TomcatDataSource) target;
    errors.pushNestedPath("general");
    dataSource.getGeneral().validate(dataSource.getGeneral(), errors);
    errors.popNestedPath();//from   w  ww  .  j a v  a2 s.c o  m
    errors.pushNestedPath("connection");
    dataSource.getConnection().validate(dataSource.getConnection(), errors);
    errors.popNestedPath();
    errors.pushNestedPath("connectionPool");
    dataSource.getConnectionPool().validate(dataSource.getConnectionPool(), errors);
    errors.popNestedPath();
}

From source file:com.springsource.hq.plugin.tcserver.serverconfig.configuration.serverdefaults.ServerDefaults.java

public void validate(Object target, Errors errors) {
    ServerDefaults serverDefaults = (ServerDefaults) target;
    errors.pushNestedPath("jspDefaults");
    serverDefaults.getJspDefaults().validate(serverDefaults.getJspDefaults(), errors);
    errors.popNestedPath();//from   ww  w .j av  a 2  s.c o  m
    errors.pushNestedPath("staticDefaults");
    serverDefaults.getStaticDefaults().validate(serverDefaults.getStaticDefaults(), errors);
    errors.popNestedPath();
}