Package org.springframework.binding.message

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


    }

  public void validateBasicInfo(PortletDefinitionForm def, MessageContext context) {
    if (StringUtils.isEmpty(def.getFname())) {
      context.addMessage(new MessageBuilder().error().source("fName")
          .code("please.enter.fname").build());
    } else if (!FunctionalNameType.isValid(def.getFname())) {
      context.addMessage(new MessageBuilder().error().source("fName")
          .code("fname.invalid").build());   
    }
   
    // if this is a new portlet and the fname is already taken
    else if (def.getId() == null && portletDefinitionRegistry.getPortletDefinitionByFname(def.getFname()) != null) {
      context.addMessage(new MessageBuilder().error().source("fName")
          .code("fname.in.use").build());
    }
   
    if (StringUtils.isEmpty(def.getTitle())) {
      context.addMessage(new MessageBuilder().error().source("title")
          .code("please.enter.title").build());
    }
   
    if (StringUtils.isEmpty(def.getName())) {
      context.addMessage(new MessageBuilder().error().source("name")
          .code("please.enter.name").build());
    }

    // if this is a new portlet and the name is already taken
    if (def.getId() == null && portletDefinitionRegistry.getPortletDefinitionByName(def.getName()) != null) {
      context.addMessage(new MessageBuilder().error().source("name")
          .code("name.in.use").build());
    }
   

  }
View Full Code Here


  }
 
  public void validateChooseCategory(PortletDefinitionForm 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("please.choose.at.least.one.category").build());
    }
  }
View Full Code Here

  }
 
  public void validateChooseGroup(PortletDefinitionForm 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("please.choose.at.least.one.group").build());
    }
  }
View Full Code Here

 
  public void validateLifecycle(PortletDefinitionForm def, ValidationContext context) {
    MessageContext messageContext = context.getMessageContext();
   
    if (def.getLifecycleState() == null) {
      messageContext.addMessage(new MessageBuilder().error().source("lifecycle")
          .code("please.select.lifecycle.stage").build());
    }
    Date now = new Date();
    if (def.getPublishDate() != null) {
      if (def.getPublishDateTime().before(now)) {
        messageContext.addMessage(new MessageBuilder().error().source("publishDate")
            .code("auto.publish.date.must.be.future").build());
      }
    }
    if (def.getExpirationDate() != null) {
      if (def.getExpirationDateTime().before(now)) {
        messageContext.addMessage(new MessageBuilder().error().source("expirationDate")
            .code("auto.expire.date.must.be.future").build());
      }
    }
    if (def.getPublishDate() != null && def.getExpirationDate() != null) {
      if (def.getExpirationDateTime().before(def.getPublishDateTime())) {
        messageContext.addMessage(new MessageBuilder().error().source("expirationDate")
            .code("auto.expire.date.must.be.after.publish").build());
      }
    }
  }
View Full Code Here

   
    public void validateEditPermission(PermissionDefinitionForm form, MessageContext messageContext) {

        // ensure at least one principal has been assigned
        if (form.getPermissions().isEmpty()) {
            messageContext.addMessage(new MessageBuilder().error().source("principal")
                .code("please.choose.at.least.one.principal").build());
        }

    }
View Full Code Here

        final Set<String> queryAttributes = personLookupHelper.getQueryAttributes(externalContext);
       
        final Map<String, Attribute> attributes = personQuery.getAttributes();
        for (final String attribute : attributes.keySet()) {
            if (!queryAttributes.contains(attribute)) {
                final MessageBuilder messageBuilder = new MessageBuilder();
                messageBuilder.error();
                messageBuilder.source("attributes[" + attribute + "].value");
                messageBuilder.code("personLookup.invalidQueryAttribute");
                messageBuilder.arg(attribute);

                final MessageResolver errorMessage = messageBuilder.build();
                context.addMessage(errorMessage);
            }
        }
    }
View Full Code Here

   */
  public void validateEditDetails(GroupForm group, MessageContext context) {
   
    // ensure the group name is set
    if(StringUtils.isBlank(group.getName())) {
      context.addMessage(new MessageBuilder().error().source("name")
          .code("please.enter.name").build());
    }
   
  }
View Full Code Here

     * Checks the keys in the Map on the model against a Set to ensure there are no values in the Map that aren't also in the Set
     */
    protected void checkAttributesMap(MessageContext context, String basePath, Set<String> swappableAttributes, Map<String, Attribute> attributesToCopy) {
        for (final String attribute : attributesToCopy.keySet()) {
            if (!swappableAttributes.contains(attribute)) {
                final MessageBuilder messageBuilder = new MessageBuilder();
                messageBuilder.error();
                messageBuilder.source(basePath + "[" + attribute + "].value");
                messageBuilder.code("x.is.not.a.valid.attribute");
                messageBuilder.arg(attribute);

                final MessageResolver errorMessage = messageBuilder.build();
                context.addMessage(errorMessage);
            }
        }
    }
View Full Code Here

    public void validateEditLocalAccount(PersonForm person, MessageContext context) {
       
        // ensure that this username isn't already taken
        if (person.getId() < 0 && accountDao.getPerson(person.getUsername()) != null) {
            context.addMessage(new MessageBuilder().error().source("username")
                    .code("username.in.use").build());
        }
       
        if (StringUtils.isNotBlank(person.getPassword()) || StringUtils.isNotBlank(person.getConfirmPassword())) {
            if (person.getPassword() == null || !person.getPassword().equals(person.getConfirmPassword())) {
                context.addMessage(new MessageBuilder().error().source("password")
                        .code("passwords.must.match").build());
            }
        }
       
    }
View Full Code Here

  // TODO replace with JSR 303
  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

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.