Package org.springframework.binding.message

Examples of org.springframework.binding.message.MessageBuilder


    }

    public void validateEnterBookingDetails(ValidationContext context) {
  MessageContext messages = context.getMessageContext();
  if (checkinDate.before(today())) {
      messages.addMessage(new MessageBuilder().error().source("checkinDate").code(
        "booking.checkinDate.beforeToday").build());
  } else if (checkoutDate.before(checkinDate)) {
      messages.addMessage(new MessageBuilder().error().source("checkoutDate").code(
        "booking.checkoutDate.beforeCheckinDate").build());
  }
    }
View Full Code Here


*/
public class StubModelValidationContext {

  public void validateMockState(ValidationContext context) {
    context.getMessageContext()
        .addMessage(new MessageBuilder().source("validationcontext").defaultText("").build());
  }
View Full Code Here

        .addMessage(new MessageBuilder().source("validationcontext").defaultText("").build());
  }

  public void validateMockState(Object model, ValidationContext context) {
    context.getMessageContext().addMessage(
        new MessageBuilder().source("validationcontext-external").defaultText("").build());
  }
View Full Code Here

* Support class for {@link ValidationHelperTest}
*/
public class StubModelMessageContext {

  public void validateMockState(MessageContext context) {
    context.addMessage(new MessageBuilder().source("messagecontext").defaultText("").build());
  }
View Full Code Here

  public void validateMockState(MessageContext context) {
    context.addMessage(new MessageBuilder().source("messagecontext").defaultText("").build());
  }

  public void validateMockState(Object model, MessageContext context) {
    context.addMessage(new MessageBuilder().source("messagecontext-external").defaultText("").build());
  }
View Full Code Here

    this.channelStore = channelRegistryStore;
  }
 
  public void validateChooseType(ChannelDefinitionForm def, MessageContext context) {
    if(def.getTypeId() == 0) {
      context.addMessage(new MessageBuilder().error().source("typeId")
          .code("errors.channelDefinition.type.empty")
          .defaultText("Please choose a channel type").build());
    }
  }
View Full Code Here

  }
 
  public void validateBasicInfo(ChannelDefinitionForm def, MessageContext context) {
    Matcher matcher = FunctionalNameType.VALID_FNAME_PATTERN.matcher(def.getFname());
    if (StringUtils.isEmpty(def.getFname())) {
      context.addMessage(new MessageBuilder().error().source("fName")
          .code("errors.channelDefinition.fName.empty")
          .defaultText("Please enter an fname").build());
    } else if (!matcher.matches()) {
      context.addMessage(new MessageBuilder().error().source("fName")
          .code("errors.channelDefinition.fName.invalid")
          .defaultText("Fnames may only contain letters, numbers, dashes, and underscores").build());   
    }
   
    // if this is a new channel and the fname is already taken
    else if (def.getId() == -1 && channelStore.getChannelDefinition(def.getFname()) != null) {
      context.addMessage(new MessageBuilder().error().source("fName")
          .code("errors.channelDefinition.fName.duplicate")
          .defaultText("This fname is already in use").build());
    }
   
    if (StringUtils.isEmpty(def.getTitle())) {
      context.addMessage(new MessageBuilder().error().source("title")
          .code("errors.channelDefinition.title.empty")
          .defaultText("Please enter a title").build());
    }
   
    if (StringUtils.isEmpty(def.getName())) {
      context.addMessage(new MessageBuilder().error().source("name")
          .code("errors.channelDefinition.name.empty")
          .defaultText("Please enter a name").build());
    }

    // if this is a new channel and the name is already taken
    if (def.getId() == -1 && channelStore.getChannelDefinitionByName(def.getName()) != null) {
      context.addMessage(new MessageBuilder().error().source("name")
          .code("errors.channelDefinition.name.duplicate")
          .defaultText("This name is already in use").build());
    }
   
View Full Code Here

            String base = param.getType().getBase();
            if ("integer".equals(base)) {
              try {
                Integer.parseInt(paramValue);
              } catch (NumberFormatException e) {
                context.addMessage(new MessageBuilder().error().source(paramPath)
                    .code("errors.channelDefinition.param.int")
                    .defaultText("Value must be an integer").build());
              }
            } else if ("float".equals(base)) {
              try {
                Float.parseFloat(paramValue);
              } catch (NumberFormatException e) {
                context.addMessage(new MessageBuilder().error().source(paramPath)
                    .code("errors.channelDefinition.param.float")
                    .defaultText("Value must be a number").build());
              }
            }
           
            // if this parameter has a restriction in the CPD,
            // check it against the restriction
            if (param.getType().getRestriction() != null
                && def.getParameters().containsKey(param.getName())) {
             
              CPDParameterTypeRestriction restriction = param.getType().getRestriction();
              if ("range".equals(restriction.getType())) {
                // For now, lets just not do anything.  It doesn't
                // look like the existing channel manager logic
                // actually uses this restriction for validation
              } else if ("enumeration".equals(restriction.getType())) {
                // if this restriction is an enumeration of allowed values, check to
                // make sure the entered value is in the enumerated list
                if (!restriction.getValues().contains(paramValue)) {
                  context.addMessage(new MessageBuilder().error().source(paramPath)
                      .code("errors.channelDefinition.param.enum")
                      .defaultText("Invalid selection").build());
                }
              }
            }
View Full Code Here

  }
 
  public void validateChooseCategory(ChannelDefinitionForm def, MessageContext context) {
    // make sure the user has picked at least one category
    if (def.getCategories().size() == 0) {
      context.addMessage(new MessageBuilder().error().source("categories")
          .code("errors.channelDefinition.param.categories.empty")
          .defaultText("Please choose at least one category").build());
    }
  }
View Full Code Here

  }
 
  public void validateChooseGroup(ChannelDefinitionForm def, MessageContext context) {
    // make sure the user has picked at least one group
    if (def.getGroups().size() == 0) {
      context.addMessage(new MessageBuilder().error().source("groups")
          .code("errors.channelDefinition.groups.empty")
          .defaultText("Please choose at least one group").build());
    }
  }
View Full Code Here

TOP

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

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.