Spring Framework
  1. Spring Framework
  2. SPR-2657

There is no way to display success message(s).

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Waiting for Triage
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      There is no way to display success message(s) like struts' ActionMessage. Spring should provide Messages inteface in a similar way of Errors and related tag libraries.

        Activity

        Hide
        Rick Evans added a comment -

        Hi Daigo

        I'm not quite sure what you mean with this issue; can you please explain a little more, perhaps supplying a use case?

        If you want to display data upon sucess, you can put the data that you want displayed in the ModelAndView.

        Cheers
        Rick

        Show
        Rick Evans added a comment - Hi Daigo I'm not quite sure what you mean with this issue; can you please explain a little more, perhaps supplying a use case? If you want to display data upon sucess, you can put the data that you want displayed in the ModelAndView. Cheers Rick
        Hide
        Daigo Kobayashi added a comment -

        Hi Rick

        Actually I can set message to ModelAndView. However, I can't handle following issue cleverly.

        1. I can't use LocaleResolver like Errors.
        2. I want to use same way as spring:hasBindErrors to handle message, so I need spring:hasBindMessages.

        Sample code:

        <spring:hasBindMessages name="command">
        <c:forEach var="msg" items="$

        {errors.globalMessages}

        ">
        <span class="message"><c:out value="$

        {msg}

        "/></span>
        </c:forEach>
        </spring:hasBindMessages>

        Show
        Daigo Kobayashi added a comment - Hi Rick Actually I can set message to ModelAndView. However, I can't handle following issue cleverly. 1. I can't use LocaleResolver like Errors. 2. I want to use same way as spring:hasBindErrors to handle message, so I need spring:hasBindMessages. Sample code: <spring:hasBindMessages name="command"> <c:forEach var="msg" items="$ {errors.globalMessages} "> <span class="message"><c:out value="$ {msg} "/></span> </c:forEach> </spring:hasBindMessages>
        Hide
        Akram BEN AISSI added a comment -

        I would be also interrested with this evolution for a secondary purpose:
        I want to display warning messages on validation:

        In fact, I want to warn (or inform) users about some validation problems (that are not critical, not errors in facts). if the user submit the form again with no changes, I want to perform the submit.

        Show
        Akram BEN AISSI added a comment - I would be also interrested with this evolution for a secondary purpose: I want to display warning messages on validation: In fact, I want to warn (or inform) users about some validation problems (that are not critical, not errors in facts). if the user submit the form again with no changes, I want to perform the submit.
        Hide
        Gunnar Hillert added a comment -

        Hi,

        This is one area where Struts is superior IMO and I wish Spring MVC would offer functionality similar to Struts' ActionMessage. (In my opinion good success messages are just as important as good error messages
        Besides providing a common infrastructure for handling error AND success messages in a standard way, it would also be great if those messages would survive redirects. Right now I am using the approach that is implemented in Matt Raible's Equinox. (Using a custom filter --> org.appfuse.web.MessageFilter).

        Also, on a side note - would it be wise to have messages support for spring core? In quite a few cases my service layer methods need to pass back messages and I wonder if that is something to 'standardize' instead of rolling your own approach?

        See also: http://forum.springframework.org/archive/index.php/t-29411.html

        Thanks!

        Regards -

        Gunnar

        Show
        Gunnar Hillert added a comment - Hi, This is one area where Struts is superior IMO and I wish Spring MVC would offer functionality similar to Struts' ActionMessage. (In my opinion good success messages are just as important as good error messages Besides providing a common infrastructure for handling error AND success messages in a standard way, it would also be great if those messages would survive redirects. Right now I am using the approach that is implemented in Matt Raible's Equinox. (Using a custom filter --> org.appfuse.web.MessageFilter). Also, on a side note - would it be wise to have messages support for spring core? In quite a few cases my service layer methods need to pass back messages and I wonder if that is something to 'standardize' instead of rolling your own approach? See also: http://forum.springframework.org/archive/index.php/t-29411.html Thanks! Regards - Gunnar
        Hide
        Andrew Wong added a comment -

        It will be very useful to have some comment framework for messaging besides just errors. Are there any plans for this issue?

        Show
        Andrew Wong added a comment - It will be very useful to have some comment framework for messaging besides just errors. Are there any plans for this issue?
        Hide
        adrian added a comment -

        I also need this feature. In the meanwhile I think we'll be developing (or borrowing) a custom one.

        SWF appears to have this feature : http://static.springsource.org/spring-webflow/docs/2.3.x/reference/htmlsingle/spring-webflow-reference.html#view-messages.
        Would be interesting to 'downgrade' it to Spring MVC ?

        JSF has a similar feature (http://wiki.apache.org/myfaces/Displaying_Errors/Infos/Warnings_in_JSF_Pages).

        <h:messages globalOnly="true" errorClass="errorMessage" infoClass="infoMessage"/>
        

        Here's the API to add an info message to the queue :

        getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, summary, null));
        

        Seam 2 (works on top of JSF) has a simple API for info messages, and a less simple for ERROR/WARN messages (http://docs.jboss.org/seam/2.2.2.Final/reference/en-US/html/framework.html#d0e8463)

        addFacesMessage("User #{user.username} already exists");
        

        Thanks !

        Show
        adrian added a comment - I also need this feature. In the meanwhile I think we'll be developing (or borrowing) a custom one. SWF appears to have this feature : http://static.springsource.org/spring-webflow/docs/2.3.x/reference/htmlsingle/spring-webflow-reference.html#view-messages . Would be interesting to 'downgrade' it to Spring MVC ? JSF has a similar feature ( http://wiki.apache.org/myfaces/Displaying_Errors/Infos/Warnings_in_JSF_Pages ). <h:messages globalOnly= " true " errorClass= "errorMessage" infoClass= "infoMessage" /> Here's the API to add an info message to the queue : getFacesContext().addMessage( null , new FacesMessage(FacesMessage.SEVERITY_INFO, summary, null )); Seam 2 (works on top of JSF) has a simple API for info messages, and a less simple for ERROR/WARN messages ( http://docs.jboss.org/seam/2.2.2.Final/reference/en-US/html/framework.html#d0e8463 ) addFacesMessage( "User #{user.username} already exists" ); Thanks !

          People

          • Assignee:
            Unassigned
            Reporter:
            Daigo Kobayashi
            Last updater:
            Chris Beams
          • Votes:
            12 Vote for this issue
            Watchers:
            12 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              2 years, 34 weeks ago