Spring Framework ObjectError - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ObjectError class.

This code example shows how to use the following methods:getField, getRejectedValue, isBindingFailure, getObjectName, getArguments
This code example shows how to use the following methods:
		return name;
	} 
 
	@Override 
	public void reject(String errorCode, Object[] errorArgs, String defaultMessage) {
		globalErrors.add(new ObjectError(name, new String[] { errorCode }, errorArgs, defaultMessage));
	} 
 
	@Override 
	public void rejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage) {
		fieldErrors.add(new FieldError(name, field, getFieldValue(field), true, new String[] { errorCode }, errorArgs,
				defaultMessage));
	} 
 
	@Override 
	public void addAllErrors(Errors errors) {
		globalErrors.addAll(errors.getAllErrors());
	} 
 
	@Override 
5
CodeRank
This code example shows how to use the following methods:getCode
This code example shows how to use the following methods:
    protected void setUp() throws Exception {
        IEmployee target = new Employee();
         
        this.callback = new DefaultErrorRenderingCallback();    
        this.errors = new BindException(target, "command");
        this.errors.addError(new ObjectError("command", new String[]{"ErrorCode1"}, null, "Default Message 1"));
        this.messageSource = new DelegatingMessageSource();
    } 
 
    public void testGetRenderingComponent() throws Exception {
        Component component = this.callback.getRenderingComponent(this.errors.getGlobalError(), this.messageSource, new Locale("it"));
        assertXpathEvaluatesTo("Default Message 1", "//div", component.render());
    } 
 
    public void testGetRenderingAction() throws Exception {
        AjaxAction action = this.callback.getRenderingAction(this.errors.getGlobalError());
        String rendering = action.render();
        assertXpathExists("//script", rendering);
        assertTrue(rendering.indexOf("new Effect.Highlight(\"ErrorCode1\",{\"startcolor\":\"#FF0A0A\"});") != -1);
    }    
5
CodeRank
This code example shows how to use the following methods:
	@Test
	@Verifies(value = "remain on the changePasswordForm page if there are errors", method = "formBackingObject()") 
	public void formBackingObject_shouldRemainOnChangePasswordFormPageIfThereAreErrors() throws Exception {
		ChangePasswordFormController controller = new ChangePasswordFormController();
		BindException errors = new BindException(controller.formBackingObject(), "user");
		errors.addError(new ObjectError("Test", "Test Error"));
		String result = controller.handleSubmission(new MockHttpSession(), "password", "differentPassword", "", "", "",
		    Context.getAuthenticatedUser(), errors);
		assertEquals("/admin/users/changePasswordForm", result);
	} 
	 
	/** 
	 * @see {@link ChangePasswordFormController#handleSubmission(HttpSession, String, String, String, String, String, User, BindingResult)} 
	 */ 
	@Test
	@Verifies(value = "set the secret question and answer of the user", method = "handleSubmission()") 
	public void handleSubmission_shouldSetTheUserSecretQuestionAndAnswer() throws Exception {
		User user = Context.getAuthenticatedUser();
		new UserProperties(user.getUserProperties()).setSupposedToChangePassword(true);
		 
4
CodeRank
This code example shows how to use the following methods:
        if (!isResponseCorrect) { 
            String objectName = "Captcha"; 
            String[] codes = {"invalid"}; 
            Object[] arguments = {}; 
            String defaultMessage = "Invalid image test entered!"; 
            ObjectError oe = new ObjectError(objectName, codes, arguments, defaultMessage); 
            errors.addError(oe); 
        } 
    } 
 
    @Override 
    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException bindException) throws Exception { 
        RegistrationCommand rc = (RegistrationCommand) command; 
 
        Person person = personService.createPerson(rc); 
 
        try { 
            mailService.sendRegistrationConfirmMail(person, RequestContextUtils.getLocale(request)); 
        } catch (MailException e) { 
            log.error("E-mail was NOT sent"); 
3
CodeRank
See Code Examples for Spring Framework ObjectError Methods: