Package org.apache.commons.validator

Examples of org.apache.commons.validator.ValidatorAction


        // check for a error message
        // check for a error message
        String min = (String) validator1.getVars().get(CommonsValidator.MIN_VARNAME);
        String max = (String) validator1.getVars().get(CommonsValidator.MAX_VARNAME);

        ValidatorAction va = CommonsValidator.getValidatorAction("doubleRange");
        assertNotNull("validator action", va);
        String actualMsg = messages.getMessage(va.getMsg(),
                facesContext.getViewRoot().getLocale(),
                new Object[] {component1.getId(), min, max});
       
        // check for a error message
        checkMessage(actualMsg, component1);
View Full Code Here


        //set the value
        component1.setSubmittedValue("11111111111111111111");
        // invoke component validation
        component1.validate(facesContext);
                       
        ValidatorAction va = CommonsValidator.getValidatorAction("creditCard");
        assertNotNull("validator action", va);
        String actualMsg = messages.getMessage(va.getMsg(),
                facesContext.getViewRoot().getLocale(),
                new Object[] {component1.getId()});
       
        // check for a error message
        checkMessage(actualMsg, component1);
View Full Code Here

        //set the value
        component1.setSubmittedValue("xyz@abc");
        // invoke component validation
        component1.validate(facesContext);
                       
        ValidatorAction va = CommonsValidator.getValidatorAction("email");
        assertNotNull("validator action", va);
        String actualMsg = messages.getMessage(va.getMsg(),
                facesContext.getViewRoot().getLocale(),
                new Object[] {component1.getId()});
       
        // check for a error message
        checkMessage(actualMsg, component1);
View Full Code Here

        //set the value
        component1.setSubmittedValue("xyz://www.wyantdata.com");
        // invoke component validation
        component1.validate(facesContext);
                       
        ValidatorAction va = CommonsValidator.getValidatorAction("url");
        assertNotNull("validator action", va);
        String actualMsg = messages.getMessage(va.getMsg(),
                facesContext.getViewRoot().getLocale(),
                new Object[] {component1.getId()});
       
        // check for a error message
        checkMessage(actualMsg, component1);
View Full Code Here


    // Test access to the 'required' validation rule
    public void testRequired() {
       
        ValidatorAction va = CommonsValidator.getValidatorAction("required");
        assertNotNull(va);
        assertEquals("required", va.getName());
        assertEquals("org.apache.shale.validator.CommonsValidator",
                va.getClassname());
        assertEquals("isSupplied",va.getMethod());
       

    }
View Full Code Here

    public void testCustom1() {

        application.setMessageBundle("org.apache.shale.validator.messages");

       
        ValidatorAction va = CommonsValidator.getValidatorAction("testRule1");
        assertNotNull(va);
        assertEquals("testRule1", va.getName());
        assertEquals("org.apache.shale.validator.CommonsValidatorTestCase",
                va.getClassname());
        assertEquals("isValid", va.getMethod());
       
       
        // find the view root
        UIViewRoot root = facesContext.getViewRoot();
        assertNotNull(root);
View Full Code Here

   
    // Test access to a custom validation rule
    public void testCustom2() {
      
        ValidatorAction va = CommonsValidator.getValidatorAction("testRule2");
        assertNotNull(va);
        assertEquals("testRule2", va.getName());
        assertEquals("org.apache.shale.validator.CommonsValidatorTestCase",
                va.getClassname());
        assertEquals("isValid", va.getMethod());
       
       
        // find the view root
        UIViewRoot root = facesContext.getViewRoot();
        assertNotNull(root);
View Full Code Here

        component1.setSubmittedValue("   ");
        // invoke component validation
        component1.validate(facesContext);
                       
       
        ValidatorAction va = CommonsValidator.getValidatorAction("required");
        assertNotNull("validator action", va);
        String actualMsg = messages.getMessage(va.getMsg(),
                facesContext.getViewRoot().getLocale(),
                new Object[] {component1.getId()});
       
        // check for a error message
        checkMessage(actualMsg, component1);
View Full Code Here


    // Test access to the 'required' validation rule with default configuration
    public void testRequired() {

        ValidatorAction va = CommonsValidator.getValidatorAction( "required" );
        assertNotNull(va);
        assertEquals("required",va.getName());
        assertEquals("org.apache.shale.validator.CommonsValidator",
                va.getClassname());
        assertEquals("isSupplied",va.getMethod());

    }
View Full Code Here

            Iterator keys = actionMap.keySet().iterator();
            while (keys.hasNext()) {
                String actName = (String) keys.next();

                // Get the Action for that name.
                ValidatorAction action = resources.getValidatorAction(actName);

                // If the result is valid, print PASSED, otherwise print FAILED
                System.out.println(
                    propertyName
                        + "["
                        + actName
                        + "] ("
                        + (result.isValid(actName) ? "PASSED" : "FAILED")
                        + ")");

                //If the result failed, format the Action's message against the formatted field name
                if (!result.isValid(actName)) {
                    success = false;
                    String message = apps.getString(action.getMsg());
                    Object[] args = { prettyFieldName };
                    System.out.println(
                        "     Error message will be: "
                            + MessageFormat.format(message, args));
View Full Code Here

TOP

Related Classes of org.apache.commons.validator.ValidatorAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.