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

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

Introduction

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

Prototype

public String getJavascript() 

Source Link

Document

Gets the Javascript equivalent of the java class and method associated with this action.

Usage

From source file:us.mn.state.health.lims.taglib.JavascriptValidatorTag.java

/**
 * Get List of actions for the given Form.
 * @param resources/*from w  ww  .j  a  v  a  2  s .  c o  m*/
 * @param form
 * @return A sorted List of ValidatorAction objects.
 */
private List createActionList(ValidatorResources resources, Form form) {

    List actionMethods = new ArrayList();

    Iterator iterator = form.getFields().iterator();
    while (iterator.hasNext()) {
        Field field = (Field) iterator.next();

        for (Iterator x = field.getDependencyList().iterator(); x.hasNext();) {
            Object o = x.next();

            if (o != null && !actionMethods.contains(o)) {
                actionMethods.add(o);
            }
        }
    }

    List actions = new ArrayList();

    // Create list of ValidatorActions based on actionMethods
    iterator = actionMethods.iterator();
    while (iterator.hasNext()) {
        String depends = (String) iterator.next();
        ValidatorAction va = resources.getValidatorAction(depends);

        // throw nicer NPE for easier debugging
        if (va == null) {
            throw new NullPointerException(
                    "Depends string \"" + depends + "\" was not found in validator-rules.xml.");
        }

        if (va.getJavascript() != null && va.getJavascript().length() > 0) {
            actions.add(va);
        } else {
            iterator.remove();
        }
    }

    Collections.sort(actions, actionComparator);

    return actions;
}