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

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

Introduction

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

Prototype

public void setClassname(String classname) 

Source Link

Document

Sets the class 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  ww w .  j a  v  a 2s  .  co 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);
}