Example usage for org.apache.commons.validator ValidatorAction setDepends

List of usage examples for org.apache.commons.validator ValidatorAction setDepends

Introduction

In this page you can find the example usage for org.apache.commons.validator ValidatorAction setDepends.

Prototype

public void setDepends(String depends) 

Source Link

Document

Sets the dependencies of the validator action.

Usage

From source file:com.sapienter.jbilling.client.payment.PaymentCrudAction.java

private void validateCreditCard() {
    // set up for cc validation, 
    // (meant for use within Validator framework)

    // from validator.xml
    Arg arg = new Arg();
    arg.setKey("all.prompt.creditCard");
    arg.setPosition(0);/*from  w ww.  j a va 2s  .c o  m*/
    Field field = new Field();
    field.addArg(arg);
    field.setProperty(FIELD_CC_NUMBER);
    field.setDepends("creditCard");

    // from validator-rules.xml
    ValidatorAction va = new ValidatorAction();
    va.setName("creditCard");
    va.setClassname("org.apache.struts.validator.FieldChecks");
    va.setMethod("validateCreditCard");
    va.setMethodParams("java.lang.Object, " + "org.apache.commons.validator.ValidatorAction, "
            + "org.apache.commons.validator.Field, " + "org.apache.struts.action.ActionErrors, "
            + "javax.servlet.http.HttpServletRequest");
    va.setDepends("");
    va.setMsg("errors.creditcard");

    // do cc number validation
    LOG.debug("doing credit card number validation");
    FieldChecks.validateCreditCard(myForm, va, field, errors, request);
}