Uploaded image for project: 'Seam International'
  1. Seam International
  2. SEAMINTL-50

Faces messages should be passed to JSF in the order they were added

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 3.0.0.Final
    • Fix Version/s: 3.1.0.Beta1
    • Component/s: Messages
    • Labels:
      None
    • Environment:

      JBAS7
      Mojarra 2.0.4 (FCS b09-jbossorg-4)

    • Steps to Reproduce:
      Hide
      Test.java
      @Named
      public class Test {
          @Inject private Messages messages;
      
          public void doTest() throws Exception {
              messages.error("msg 1");
              messages.info("msg 2");
              messages.warn("msg 3");
              messages.warn("msg 4");
      
              messages.warn("msg 5");
              messages.warn("msg 6");
              messages.warn("msg 7");
      
              messages.warn("msg 8");
              messages.warn("msg 9");
              messages.info("msg 10");
              messages.error("msg 11");
              messages.error("msg 12");
          }
      }
      
      test.xhtml
      <ui:composition xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:ui="http://java.sun.com/jsf/facelets">
          <h:messages/>
          <h:form>
              <h:commandButton action="#{test.doTest}" value="Test"/>
          </h:form>
      </ui:composition>
      
      Show
      Test.java @Named public class Test { @Inject private Messages messages; public void doTest() throws Exception { messages.error( "msg 1" ); messages.info( "msg 2" ); messages.warn( "msg 3" ); messages.warn( "msg 4" ); messages.warn( "msg 5" ); messages.warn( "msg 6" ); messages.warn( "msg 7" ); messages.warn( "msg 8" ); messages.warn( "msg 9" ); messages.info( "msg 10" ); messages.error( "msg 11" ); messages.error( "msg 12" ); } } test.xhtml <ui:composition xmlns:h = "http://java.sun.com/jsf/html" xmlns:ui = "http://java.sun.com/jsf/facelets" > <h:messages/> <h:form> <h:commandButton action= "#{test.doTest}" value= "Test" /> </h:form> </ui:composition>
    • Estimated Difficulty:
      Low

      Description

      The MessagesImpl bean does not preserve messages in the order they were added; the order they are output (using <h:messages>) is random.

      I've submitted a github pull request; the fix simply uses LinkedHashSet's instead of HashSets. I've tested it, it works for me.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                kenfinni Ken Finnigan
                Reporter:
                mazi Matija Mazi
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: