Package org.springframework.validation

Examples of org.springframework.validation.Errors


    @Test
    public void testValidate_InvalidPageSize() throws Exception {
        Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
        preferenceMap.put(PAGE_SIZE, new PortalPreferenceImpl(PAGE_SIZE, "10.5"));
        PortalPreferenceForm form = new PortalPreferenceForm(preferenceMap);
        Errors errors = new BindException(form, "form");
        validator.validate(form, errors);

        assertEquals(1, errors.getErrorCount());
        assertNotNull(errors.getFieldError("pageSize.value"));
    }
View Full Code Here


                    }
                }
            }
        }

        Errors errors = requestContext.getErrors(formName, false);
        List fes = null;
        if (errors != null) {
            fes = errors.getFieldErrors(fieldName);
            //String errorMsg = getErrorMessages(fes);
        }

        if (fes != null && fes.size() > 0) {
            validationError = true;
View Full Code Here

    @Override
    protected boolean onUnmarshalRequest(MessageContext messageContext, Object requestObject) throws Exception {
        Validator[] validators = getValidators();
        if (validators != null) {
            Errors errors = new BindException(requestObject, getRequestName());
            for (Validator validator : validators) {
                ValidationUtils.invokeValidator(validator, requestObject, errors);
            }
            if (errors.hasErrors()) {
                return onValidationErrors(messageContext, requestObject, errors);
            }
        }
        return true;
    }
View Full Code Here

                            // Set event properties:
                            this.initEvent(event, request);
                            Map model = this.getModel(request.getSession());
                            if (model != null) {
                                Object commandObject = this.formDataAccessor.getCommandObject(request, response, handler, model);
                                Errors errors = this.formDataAccessor.getValidationErrors(request, response, handler, model);
                                event.setCommandObject(commandObject);
                                event.setValidationErrors(errors);
                                event.setModel(model);
                            }
                            // Handle event:
View Full Code Here

    public void testGetValidator() throws Exception {
        DefaultValidatorFactory factory = getFactory();

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

        Errors errors = (Errors) control.getMock();
        Object bean = new Object();

        Validator val = factory.getValidator("fooBean", bean, errors);
        assertSame(val.getParameterValue(Validator.BEAN_PARAM), bean);
        assertSame(val.getParameterValue(DefaultValidatorFactory.ERRORS_KEY), errors);
View Full Code Here

        Field field = createFieldForProperty("name");

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

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        boolean result = FieldChecks.validateRequired(bean, validatorAction, field, errors);
        assertFalse(result);
    }
View Full Code Here

        field.addVar("test", "(*this* < 10)", "");

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

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

View Full Code Here

        field.addVar("test", "(*this* > -10.43)", "");

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

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

View Full Code Here

        field.addVar("test", "(*this* != null)", "");

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

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

View Full Code Here

        field.addVar("test", "(*this* == 'uri')", "");

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

        ValidatorAction validatorAction = new ValidatorAction();
        Errors errors = (Errors) control.getMock();

        ValidatorResources vr = new ValidatorResources();
        vr.process();
        Validator validator = new Validator(vr);

View Full Code Here

TOP

Related Classes of org.springframework.validation.Errors

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.