Package org.springframework.binding.message

Examples of org.springframework.binding.message.MessageContext


     * then it sends back error message.
     * @param context
     */
    public void validateRecordretrieval(ValidationContext context)
    {
        MessageContext messages = context.getMessageContext();
        if (StringUtils.isEmpty(recordURI))
        {
            messages.addMessage(new MessageBuilder().error().source("recordURI").
            defaultText("Record URI can not be blank").build());
        }
    }
View Full Code Here


    public void validateEnterSearchCriteria(ValidationContext context)
    {
       
        if (this.isEmpty())
        {
            MessageContext messages = context.getMessageContext();
            messages.addMessage(new MessageBuilder().error().defaultText(
                "At least one of the Search criteria should not be empty.")
                    .build());
           
        }
        else if (lastName.startsWith("*") || firstName.startsWith("*")
                || bookingId.startsWith("*") || activityDate.startsWith("*"))
        {
            MessageContext messages = context.getMessageContext();
            messages.addMessage(new MessageBuilder().error().defaultText(
                "Search criterion can not start with '*'.").build());
        }else if(!activityDate.isEmpty()){
            SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy");

            boolean error = false;
           
            if (activityDate.trim().length() != dateFormat.toPattern().length())
            {
                log.error("Activity date has invalid format.");
                error = true;
           

            dateFormat.setLenient(true);
           
            try {
              //parse the inDate parameter
              dateFormat.parse(activityDate.trim());
            }
            catch (ParseException pe) {
                log.error("Activity date has invalid format.");
                error = true;
            }
           
            if (error == true)
            {   
                MessageContext messages = context.getMessageContext();
                messages.addMessage(new MessageBuilder().error().defaultText(
                    "Activity date has invalid format. Please enter in mm/dd/yy format").build());
            }   
           
        }
       
View Full Code Here

    Assert.state(!started, "This flow has already been started; you cannot call 'start()' more than once");
    if (logger.isDebugEnabled()) {
      logger.debug("Starting in " + externalContext + " with input " + input);
    }
    started = true;
    MessageContext messageContext = createMessageContext(null);
    RequestControlContext requestContext = createRequestContext(externalContext, messageContext);
    RequestContextHolder.setRequestContext(requestContext);
    listeners.fireRequestSubmitted(requestContext);
    try {
      start(flow, input, requestContext);
View Full Code Here

    }
    if (logger.isDebugEnabled()) {
      logger.debug("Resuming in " + externalContext);
    }
    Flow activeFlow = getActiveSessionInternal().getFlow();
    MessageContext messageContext = createMessageContext(activeFlow.getApplicationContext());
    RequestControlContext requestContext = createRequestContext(externalContext, messageContext);
    RequestContextHolder.setRequestContext(requestContext);
    listeners.fireRequestSubmitted(requestContext);
    try {
      listeners.fireResuming(requestContext);
View Full Code Here

    public void setAmenities(Set<Amenity> amenities) {
  this.amenities = amenities;
    }

    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 void testValidateWithMessageContext() {
    Object model = new StubModelMessageContext();
    ValidationHelper helper = new ValidationHelper(model, requestContext, eventId, modelName, null, null, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
    assertEquals(1, messages.getMessagesBySource("messagecontext").length);
    assertEquals(0, messages.getMessagesBySource("validationcontext").length);
  }
View Full Code Here

  public void testValidateWithValidationContext() {
    Object model = new StubModelValidationContext();
    ValidationHelper helper = new ValidationHelper(model, requestContext, eventId, modelName, null,
        this.codesResolver, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
    assertEquals(1, messages.getMessagesBySource("validationcontext").length);
  }
View Full Code Here

    applicationContext.registerSingleton("modelValidator", StubModelMessageContext.class);
    ((Flow) requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    ValidationHelper helper = new ValidationHelper(new Object(), requestContext, eventId, modelName, null,
        this.codesResolver, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
    assertEquals(1, messages.getMessagesBySource("messagecontext-external").length);
  }
View Full Code Here

    applicationContext.registerSingleton("modelValidator", StubModelValidationContext.class);
    ((Flow) requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    ValidationHelper helper = new ValidationHelper(new Object(), requestContext, eventId, modelName, null,
        this.codesResolver, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
    assertEquals(1, messages.getMessagesBySource("validationcontext-external").length);
  }
View Full Code Here

    applicationContext.registerSingleton("modelValidator", StubModelErrors.class);
    ((Flow) requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    ValidationHelper helper = new ValidationHelper(new Object(), requestContext, eventId, modelName, null,
        this.codesResolver, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
    assertEquals(1, messages.getMessagesBySource("errors-external").length);
  }
View Full Code Here

TOP

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

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.