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

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

Introduction

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

Prototype

public void setMethod(String method) 

Source Link

Document

Sets the name of method being called for 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 w w.  j  a  v  a2 s.  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);
}