Package org.springframework.validation

Examples of org.springframework.validation.ObjectError


    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(new ObjectError("confirmPassword.required", "Confirm password required"));

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
View Full Code Here


    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(new ObjectError("password.invalid.length", "Password must be atleast 4 characters long"));

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
    replay(model);
View Full Code Here

    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(new ObjectError("confirmPassword.mismatch", "Password mismatch"));

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
    replay(model);
View Full Code Here

    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(new ObjectError("confirmPassword.mismatch", "Password mismatch"));

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
        replay(model);
View Full Code Here

    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(new ObjectError("username.required", "Username required"));
    errorList.add(new ObjectError("password.required", "Password required"));
    errorList.add(new ObjectError("confirmPassword.required", "Confirm password required"));

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
View Full Code Here

    @Test
    public void testValidationCollectedWithErrors() {
        assertValidationOperation(
                createMockErrors("testValidationCollectedWithErrors", Arrays.asList(
                        new ObjectError("curDate", new Date().toString()),
                        new ObjectError("curTime", String.valueOf(System.currentTimeMillis())),
                        new ObjectError("className", getClass().getSimpleName())
                )));
    }
View Full Code Here

    private static OperationList assertValidationErrors(OperationList errDetails, Errors errors) {
        assertEquals("Mismatched number of errors", errors.getErrorCount(), errDetails.size());

        List<? extends ObjectError> errList = errors.getAllErrors();
        for (int index = 0; index < errList.size(); index++) {
            ObjectError expected = errList.get(index);
            OperationMap actual = errDetails.get(index, OperationMap.class);
            assertNotNull("Missing encoded value for error #" + index + ": " + expected, actual);

            String objName = actual.get(OperationUtils.NAME_KEY, String.class);
            assertEquals("Mismatched object name at entry #" + index, expected.getObjectName(), objName);

            String errExpected = StringUtil.chopTailAndEllipsify(expected.toString(), ValidationJoinPointFinalizer.MAX_ERROR_TEXT_LENGTH);
            String errActual = actual.get(OperationUtils.VALUE_KEY, String.class);
            assertEquals("Mismatched error text at entry #" + index, errExpected, errActual);
        }

        return errDetails;
View Full Code Here

    if (messages.length == 0) {
      return Collections.emptyList();
    }
    List<ObjectError> errors = new ArrayList<ObjectError>(messages.length);
    for (Message message : messages) {
      errors.add(new ObjectError(objectName, message.getText()));
    }
    return Collections.unmodifiableList(errors);
  }
View Full Code Here

            String messageCode = "invalidRequestBody";
            Class objectType = object.getClass();
            String defaultMessage = "An error occurred parsing the body of the request";
            String[] codes = getMessageCodes(messageCode, objectType);
            bindingResult = new BeanPropertyBindingResult(object, objectType.getName());
            bindingResult.addError(new ObjectError(bindingResult.getObjectName(), codes, null, defaultMessage));
        } catch (Exception e) {
            bindingResult = new BeanPropertyBindingResult(object, object.getClass().getName());
            bindingResult.addError(new ObjectError(bindingResult.getObjectName(), e.getMessage()));
        }

        if (domain != null && bindingResult != null) {
            BindingResult newResult = new ValidationErrors(object);
            for (Object error : bindingResult.getAllErrors()) {
View Full Code Here

                    else {
                        json.property("message", fe.getDefaultMessage());
                    }
                    writer.endObject();
                } else if (o instanceof ObjectError) {
                    ObjectError fe = (ObjectError) o;
                    writer.object();
                    json.property("object", fe.getObjectName());
                    Locale locale = LocaleContextHolder.getLocale();
                    if (applicationContext != null) {
                        json.property("message", applicationContext.getMessage(fe, locale));
                    }
                    else {
                        json.property("message", fe.getDefaultMessage());
                    }
                    writer.endObject();
                }
            }
            writer.endArray();
View Full Code Here

TOP

Related Classes of org.springframework.validation.ObjectError

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.