Package org.apache.commons.validator

Examples of org.apache.commons.validator.Field


                final Form validatorForm = getValidatorResources().getForm(
                    Locale.getDefault(),
                    this.formId);
                if (validatorForm != null)
                {
                    final Field field = this.getFormField(validatorForm, component.getId());
                    if (field != null)
                    {
                        final Collection errors = new ArrayList();
                        this.getValidatorMethod().invoke(
                            this.getValidatorClass(),
View Full Code Here


     */
    private Field getFormField(
        final Form form,
        final String fieldName)
    {
        Field field = null;
        if (form != null)
        {
            field = form.getField(fieldName);
        }
        return field;
View Full Code Here

                    if (validatorForm != null)
                    {
                        final java.util.List validatorFields = validatorForm.getFields();
                        for (final Iterator iterator = validatorFields.iterator(); iterator.hasNext();)
                        {
                            final Field field = (Field)iterator.next();

                            // we need to make it match the name of the id on the jsf components (if its nested).
                            final String fieldProperty = StringUtilsHelper.lowerCamelCaseName(field.getProperty());
                            if (componentId.equals(fieldProperty))
                            {
                                for (final Iterator dependencyIterator = field.getDependencyList().iterator();
                                    dependencyIterator.hasNext();)
                                {
                                    final String dependency = (String)dependencyIterator.next();
                                    final ValidatorAction action = JSFValidator.getValidatorAction(dependency);
                                    if (action != null)
                                    {
                                        final JSFValidator validator = new JSFValidator(formId, action);
                                        final Arg[] args = field.getArgs(dependency);
                                        if (args != null)
                                        {
                                            for (final Iterator varIterator = field.getVars().keySet().iterator(); varIterator.hasNext();)
                                            {
                                                final String name = (String)varIterator.next();
                                                validator.addParameter(
                                                    name,
                                                    field.getVarValue(name));
                                            }
                                            validator.setArgs(ValidatorMessages.getArgs(
                                                    dependency,
                                                    field));
                                            this.addValidator(
View Full Code Here

        if (resources != null) {
            Form form = resources.getForm(locale, formName);

            if (form != null) {
                Field field = form.getField(fieldName);

                if (field != null) {
                    if (field.isDependency("required") || field.isDependency("validwhen")) {
                        requiredField = true;
                    }
                }
            }
        }
View Full Code Here

    public void testExtractValueWithMap() {
        String name = "Rob Harrop";
        String property = "name";

        Field field = new Field();
        field.setProperty(property);

        Map bean = new HashMap();
        bean.put(property, name);

        String result = FieldChecks.extractValue(bean, field);
View Full Code Here

        int age = 23;

        String property1 = "name";
        String property2 = "age";

        Field field1 = createFieldForProperty(property1);
        Field field2 = createFieldForProperty(property2);

        MockValidationBean validationBean = new MockValidationBean();
        validationBean.setName(name);
        validationBean.setAge(age);
View Full Code Here

        String ageResult = FieldChecks.extractValue(validationBean, field2);
        assertEquals("" + age, ageResult);
    }

    public void testExtractWithNullBean() {
        String result = FieldChecks.extractValue(null, new Field());
        assertNull(result);
    }
View Full Code Here

    public void testValidateRequiredSuccess() {
        MockValidationBean bean = new MockValidationBean();
        bean.setName("Rob Harrop");

        Field field = createFieldForProperty("name");

        boolean result = FieldChecks.validateRequired(bean, null, field, null);
        assertTrue(result);
    }
View Full Code Here

        assertTrue(result);
    }

    public void testValidateRequiredError() {
        MockValidationBean bean = new MockValidationBean();
        Field field = createFieldForProperty("name");

        MockControl control = MockControl.createControl(Errors.class);

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();
View Full Code Here

    }

    public void testValidateWhenValid_Success() throws Exception {
        MockValidationBean bean = new MockValidationBean();
        bean.setAge(5);
        Field field = createFieldForProperty("age");
        field.addVar("test", "(*this* < 10)", "");

        MockControl control = MockControl.createControl(Errors.class);

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();
View Full Code Here

TOP

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

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.