Package org.springframework.binding.message

Examples of org.springframework.binding.message.MessageBuilder$ResolvableArgument


        "componentId"), new FacesMessage("componentId_summary1", "componentId_detail1")));
    this.prepopulatedMessageContext.addMessage(new FlowFacesContext.FlowFacesMessage(new FacesMessageSource(
        "componentId"), new FacesMessage("componentId_summary2", "componentId_detail2")));
    this.prepopulatedMessageContext.addMessage(new FlowFacesContext.FlowFacesMessage(new FacesMessageSource(null),
        new FacesMessage("baz")));
    this.prepopulatedMessageContext.addMessage(new MessageBuilder().source("userMessage").defaultText("userMessage")
        .info().build());
    this.prepopulatedMessageContext.addMessage(new MessageBuilder().defaultText("Subzero Wins - Fatality").fatal()
        .build());
  }
View Full Code Here


    assertEquals(0, model.getErrorCount());
    assertEquals(0, model.getFieldErrorCount());
  }

  public void testGetFieldError() {
    messages.addMessage(new MessageBuilder().source("datum2").error().defaultText("Error").build());
    assertEquals(1, model.getErrorCount());
    assertEquals(1, model.getFieldErrorCount());
    assertEquals(0, model.getGlobalErrorCount());

    FieldError error = model.getFieldError("datum2");
View Full Code Here

    FieldError error2 = model.getFieldErrors().get(0);
    assertEquals(error, error2);
  }

  public void testGetFieldErrorsWildcard() {
    messages.addMessage(new MessageBuilder().source("datum2").error().defaultText("Error").build());
    assertEquals(1, model.getFieldErrorCount("da*"));
    FieldError error = model.getFieldError("da*");
    assertEquals(null, error.getCode());
    assertEquals(null, error.getCodes());
    assertEquals(null, error.getArguments());
View Full Code Here

    assertEquals("test", model.getFieldValue("datum1"));
    assertEquals("0", model.getFieldValue("datum2"));
    Class<?> clazz = model.getFieldType("datum2");
    assertTrue(int.class.equals(clazz) || Integer.class.equals(clazz));

    messages.addMessage(new MessageBuilder().source("nestedBean.datum2").error().defaultText("Error").build());
    assertNotNull(model.getFieldErrors("datum2").get(0));
    model.popNestedPath();
    assertEquals("", model.getFieldValue("datum1"));
  }
View Full Code Here

  protected MessageResolver createMessageResolver(MappingResult error) {
    String model = getModelExpression().getExpressionString();
    String field = error.getMapping().getTargetExpression().getExpressionString();
    Class<?> fieldType = error.getMapping().getTargetExpression().getValueType(getModelObject());
    String[] messageCodes = messageCodesResolver.resolveMessageCodes(error.getCode(), model, field, fieldType);
    return new MessageBuilder().error().source(field).codes(messageCodes).resolvableArg(field)
        .defaultText(error.getCode() + " on " + field).build();
  }
View Full Code Here

    return bookstoreService.store(order).getId();
  }

  public Event validateDeliveryDate(OrderForm orderForm, MessageContext messageContext) {
    if (orderForm.getDeliveryDate() == null) {
      MessageBuilder errorMessageBuilder = new MessageBuilder().error();
      errorMessageBuilder.source("deliveryDate");
      errorMessageBuilder.code("error.page.selectdeliveryoptions.deliverydate.required");
      messageContext.addMessage(errorMessageBuilder.build());
      return new EventFactorySupport().error(this);
    }

    if (!orderForm.getDeliveryDate().after(DateUtils.truncate(orderForm.getOrderDate(), Calendar.DAY_OF_MONTH))) {
      MessageBuilder errorMessageBuilder = new MessageBuilder().error();
      errorMessageBuilder.source("deliveryDate");
      errorMessageBuilder.code("error.page.selectdeliveryoptions.deliverydate.in.past");
      messageContext.addMessage(errorMessageBuilder.build());
      return new EventFactorySupport().error(this);
    }
    return new EventFactorySupport().success(this);
  }
View Full Code Here

  public void validateSelectCategory(ValidationContext context) {
    if (context.getUserEvent().equals("next")) {
      MessageContext messages = context.getMessageContext();
      if (category == null) {
        messages.addMessage(new MessageBuilder().error().source("category")
            .code("error.page.category.required").build());
      }
    }
  }
View Full Code Here

  public void validateSelectBooks(ValidationContext context) {
    if (context.getUserEvent().equals("next")) {
      MessageContext messages = context.getMessageContext();
      if (books.isEmpty()) {
        messages.addMessage(new MessageBuilder().error().source("books").code("error.page.books.required")
            .build());
      }
    }
  }
View Full Code Here

   
    public void validateEnterPassword(AccountPasswordForm form, MessageContext context) {
       
        // ensure that a current account password was entered
        if (StringUtils.isBlank(form.getCurrentPassword())) {
            context.addMessage(new MessageBuilder().error().source("currentPassword")
                    .code("please.enter.current.password")
                    .defaultText("Please enter your current password").build());
        }
       
        // check to see if the provided password matches the current account
        // password
        else {
           
            ILocalAccountPerson account = accountDao.getPerson(form.getUserId());
            if (!passwordService.validatePassword(form.getCurrentPassword(), account.getPassword())) {
                context.addMessage(new MessageBuilder().error().source("currentPassword")
                        .code("current.password.doesnt.match")
                        .defaultText("Provided password does not match the current account password").build());
            }

        }
       
        // ensure a new account password was entered
        if (StringUtils.isBlank(form.getNewPassword())) {
            context.addMessage(new MessageBuilder().error().source("newPassword")
                    .code("please.enter.new.password")
                    .defaultText("Please enter a new password").build());
        }
       
        // ensure a new account password confirmation was entered
        if (StringUtils.isBlank(form.getConfirmNewPassword())) {
            context.addMessage(new MessageBuilder().error().source("confirmNewPassword")
                    .code("please.enter.confirm.password")
                    .defaultText("Please confirm your new password").build());
        }
       
        // ensure the new password and new password confirmation match
        if (StringUtils.isNotBlank(form.getNewPassword())
                && StringUtils.isNotBlank(form.getConfirmNewPassword())
                && !form.getNewPassword().equals(form.getConfirmNewPassword())) {
           
            context.addMessage(new MessageBuilder().error().source("confirmPassword")
                    .code("passwords.must.match")
                    .defaultText("Passwords must match").build());
        }
       
    }
View Full Code Here

        final int selectedTypeId = def.getTypeId();

        switch (selectedTypeId) {
            case 0:
                // No type selected...
                context.addMessage(new MessageBuilder().error().source("typeId")
                    .code("please.choose.portlet.type").build());
                break;
            default:
                // User specified a typeId;  validate that it exists
                final PortletPublishingDefinition cpd = channelPublishingDefinitionDao.getChannelPublishingDefinition(selectedTypeId);
                if (cpd == null) {
                    context.addMessage(new MessageBuilder().error().source("typeId")
                            .code("please.choose.portlet.type").build());
                }
                break;
        }
View Full Code Here

TOP

Related Classes of org.springframework.binding.message.MessageBuilder$ResolvableArgument

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.