h:messages tag display order

From my observations, it seems that messages displayed by the messages tag show up with the messages created first at the end of the list (or table). On the surface, this makes sense --new messages are thrown on the pile, so to speak.  But this is the complete reverse order from how the fields show up on the form. Fields at the top of the form, which are validated first, show up on the bottom of the list. Fields at the bottom of the form, show up first. Not very intuitive for the user.
Here are the options as I see them:
1) write a custom component extending the messages component with the desired sorting behavior
2) abandon the messages component, and code a panelGrid of message components for every field on the form (in the desired order).
3) find a third party component... this seems basic enough so maybe this is already part of myFaces or ADF. So far, I've been getting by with the components included in the RI. Will something this trivial force me to switch?
What are the approaches that I've missed?

Here is an easy solution without having to create a custom component. I have a superclass bean for all of my backing beans with common functionality. In the validate() of my superclass bean I check for any messages to determine navigation and also capture all messages into a list if there are any.
     protected String validate() {
         String result = "success";
         FacesContext context = FacesContext.getCurrentInstance();
                    if(context.getMessages().hasNext()){
             Iterator i = context.getMessages();
             while(i.hasNext()){
          FacesMessage message = (FacesMessage)i.next();
          errorMessages.add(message.getDetail());
             result = null;
         return result;
     }On the jsp I use JSTL to list the messages.
<span style="width:100%">
     <h:outputText value="#{appBundle.ERR_HEADER}<br/>" escape="false" rendered="#{SelectAccountBean.messages == true}" styleClass="title"/>     
     <c:forEach items="${SelectAccountBean.errorMessages}" var="msg">
          <c:out value="<span class='message'>${msg}</span>" escapeXml="false"/>
     </c:forEach>
     <h:outputText value="<br/>" escape="false" rendered="#{SelectAccountBean.messages == true}"/>          
        </span>Edited by: minicpt on Jul 31, 2008 2:05 PM

Similar Messages

  • H:messages - Display order

    Hi,
    I have a form where the user enters *(1.zipcode 2.phone number 3.email address)* and i am using h:messages to display the messages at the top of the page. I would like the error messages to be displayed in the order of input field validations. JSF1.2 is displaying error messages in random order.
    Scenario:+
    User leaves all the fields blank and clicks submit.
    Error messages are displayed in some order by JSF1.2:
    Please enter email address.
    Please enter phone number.
    Please enter zipcode.
    I want them to be displayed in this order:
    Please enter zipcode.
    Please enter phone number.
    Please enter email address.
    Is there a way i can specify to JSF to display the error messages in the order of input field validations?
    Appreciate your help.
    Thanks
    vamsi

    The standard messages component will output the messages in the order they are queued by the code. Do you have something unusual happening that would change the order of the component validation?
    In any case, some potential solutions:
    1) Use <h:message> with the for attribute and place the messages in the order you desire.
    2) Create a custom messages component, which provides a sorting interface.
    3) Use a PhaseListener to rebuild the message queue in the correct order before the Render Response phase (depends on the Iterators returned from FacesContext.getMessages() being modifiable).

  • Displaying messages without h:message or h:messages tag

    How can you display messages without h:message or h:messages tag. Is it possible to disply messages in another component. I have only a small piece of page reserved for displaying errors and it would be nice to show these errors in component with scrollbar.
    Regards, Simy

    Well you can access messages produced using
    getMessages() method of faces context. Store these messages in some attribute of backing bean and attach this attribute to some component in your jsf page.
    You can use the following conditions to determine the presence of any messages using:
    rendered="#{! empty facesContext.maximumSeverity}"

  • Using EL variable in struts bean:message tag(not struts EL tag)

    Is there any work around to use an EL variable inside struts bean:message tag as key:
    I have like this:
    <bean:message key="${bean.keyName}"/>
    which is throwing error , I know this can be resolved by using struts-el tags but i cannot use them for specific reasons.
    I dont want to use bean:define tag to define my 'bean' and then use like this:
    <bean:message key="<%=bean.getKeyName%>"/> (this actually works, but i want to use EL variable)
    Is there any work around to use EL variable and make the message display on the jsp.
    i tried multiple ways like scriplets and jsp:useBean but nothing worked, Please let me know..
    Thanks in advance

    Im pretty sure that EL does not work in the normal struts tag unless its struts-el tag.Have you tried it?
    As I said, in a properly configured JSP2.0 container you can use EL expressions anywhere you could traditionally use a standard runtime expression <%= expr %>.
    What server are you using? What JSP version?
    The Struts-el tags were written so that you could use EL with struts in JSP1.2 containers.
    The c_rt tags were written so you could use runtime expressions with JSTL tags in JSP1.2 containers. Their use was discouraged even then. Now I consider their use absolutely unnecessary.
    Please read this thread: http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0
    Cheers,
    evnafets

  • How to Configure a Pop Up Message in Sales Orders

    Hi,
    How can I display a message when creating or changing sales orders? I need the configuration steps for 4.6.
    Thanks,
    Sai.

    Hi,
    First you need to make an entry of your pop up message in the sales text view of the material master and when the user enters that material, he will be able to see that message. The Config part is in spro/sd/basic func/text control. You need to define the text types, access sequences and the text determ procedures.
    You have to maintain the desired text in the material master sales text editor and turn on the indicator 'Display texts during transfer' under Text control in configuration for the sales order-item for the material sales text. This will display a Pop-up message when booking orders
    Reward points if found helpfull...
    Cheers,
    Siva.

  • Customer error message in sales order on save

    Hi Friends,
    as per requirement i have to raise the error message and system should enable the field to change values. This should happen when condition is not met on Saving of Sales order.
    For this, i have used the user exit USEREXIT_SAVE_DOCUMENT_PREPARE. But the problem is system throwing error message and all r in display mode only. as per my requirement system should allow to change the error value field.
    i have verified many posting in this SDN, but nothing is working out.
    Please guide me, how to raise the error message and system should enable that filed.
    My doubt is where should i raise the error message in sales order (MV45AFZZ)??? if any badi to raise the error message also fine for me. I tried many ways like... message with display like..... and set / get parameters and badis....  but not able to find the correct solution.
    Thanks in Advance.
    Bala

    Hi
    You need to use check for enahcement spot, which will be help to you.
    Bcz you are throwing custom error message in the standard transaction, once the error is display, you could not able to change the values. your prob can be solved by using the enhancement sport.
    This is include name (Include:MV45AF0B_BELEG_SICHERN).
    In the above include, you need to create a enhancement spot after this spot (ENHANCEMENT 16  OI0_COMMON_SAPMV45A.)  
    write your custom code and while displaying an error message. set flag = 'x', then use below code. It will display error message once you press ENTER, you will get the sale order in change mode, you change the values.
      IF flag = 'X'.
              fcode = fcode_gleiche_seite.
              perform fcode_bearbeiten.
              ch_subrc = 4.
              exit.
            ENDIF.

  • Collect message log after order TECO

    Hi,
    In Tcode iw31/iw32 I am making the order as TECO. Order is made Completed (technically). But my issue is when I TECO the order i need to get back error/success messages in LOG option available in this Tcode.
    TECO the order:
    Menu:
    Order->Functions->Complete->Complete(Technically)
    Now after doign TECO I need back messages in place below:
    Menu:
    GoTo->Log->Complete
    Here I am not able to get any messages after TECO.
    Is there any place available so that i can  use ABAP code to get back messages here.
    Pls suggest.
    Thanks.

    Hi Hrishi,
    Actually I have requirement that,  during TECO of order I m calling one Z Function module  which do some processing, in this FM I am collecting Error/Success messages which occurs during this Z FM processing.
    I need back those return messages and display in IW32 LOG menu. i.e Goto->Log->Complete
    Alternativley I am finding MENU exit related to this Tcode so that I can add extra menu and display those messages on click of this menu.
    Thanks.

  • H:messages tag

    How do i control the order of the messages. Suppose if i add messages 1,2,3 ..., it displays in random order.
    It is not displaying the messages in the order it is added . Is there any attribute ? or is there any otherway to acheive the ordering .
    If any body know ,throw some light.
    Thank you.

    In Sun's RI, messages are stored in a HashMap in which keys are their clinetIds.
    The order of adding messages is not recorded.
    You should develop a subclass of FacesContextImpl and override methods such that
    addMessage and getMessages.

  • How can I increase the number of Tags displayed in Drop down list?

    When I go to Bookmarks/Tags, there are only 10 tags displayed. I have created at least 15 tags.
    Is there a way to increase the number of Tags displayed in the Drop down list?
    Thanks

    Do you mean "Recent Tags" which has an icon a blue-colored folder with a primitive looking magnifying glass over the folder?
    That folder does have a limit of 10 results. If you want to create an "All Tags" item on the Boomarks Menu, you can do that by creating your own "smart folder." The process I use is a little involved, so bear with me (also, see the screen shots).
    The query used by Recent Tags is:
    place:type=6&sort=14'''&maxResults=10'''
    So for All Tags we will drop the maximum results limit:
    place:type=6&sort=14
    ''If you prefer your tags in alphabetical order instead of having the most recently used at the top, use this instead:''
    place:type=6&sort=1
    Go ahead and select the line you want and right-click > copy it.
    Next, click the bookmarks drop-down button, expand the Bookmarks Toolbar, right-click any existing item, and choose New Bookmark.
    In Location, paste the query, and in name, type All Tags (or your preferred description). When you click Add Bookmark, Firefox will add it, but it doesn't show the blue search folder icon. Drag the bookmark to the menu, and it will turn into a functioning search folder.
    Success?

  • How to use h:message to display HTML code in message from property file

    I am using <h:message for="somecomponentid"/> to display the error message for a validator attached to a component and the error message which resides in message property file contains HTML elements like <br> and
    The HTML doesnt get displayed properly and the code <br> etc is displayed instead.
    Is there a method to get h:message to display HTML elements correcly.
    [I know there is an h:outputFormat which has an escape parameter to allow HTML to be rendered correcly but it has no for parameter to specify the component id whose validation error message I want to display]
    eg.
    <h:message for="somecomponentid"/>
    to display from errormessages.properties
    com.somecompany.thevalidationerrormessage=You have an error<br> Please click here to return to homepage

    Hello Ivan,
    Fortunately I have just recently found a solution to my problem by using code by a developer who had already had this problem in the past and who provided a patch on the Apache MyFaces jira site.
    See following link for the solution I downloaded and then used :
    http://issues.apache.org/jira/browse/MYFACES-155
    I believe they are intending to eventually release this in a future release of MyFaces extensions on this site.
    I used the escape attribute on the tag to allow 'escaped' html code in error messages to be used.
    Hope it solves your problem too..
    Suhel

  • Assigning display order to prompts designed in universe

    Hi,
    Is there a way assigning display order to prompts designed in universe?
    Currently I have achieved it though appending numeric numbers like 1, 2...at the begining of the prompt text. But when I added a new prompt it is coming in between of the existing prompts where as I have already added a numeric value to it.
    For ex: I have following 4 existing prompts.
    1. Select Granularity
    2. Enter Data/Time
    3. Select Network View
    4. Select BSC Name
    The new prompt I have designed as 5. Select Time Zone Offset. Now this prompt is coming in between 3. Select Network View and 4. Select BSC Name prompt.
    I am surprised with this behavior. Is there a solution for this?
    Thanks,
    Sus.
    Edited by: SUS_India on Apr 20, 2009 4:18 PM

    If this is the case then "Prompt Order works as per the user:xx parameter in @prompt". As user:xx is reserved for Webi only, we can not use it in the universe while designing the prompts and can not achieve the prompt display order.
    That's why I have appended the Numeric numbers in the prompts message to achieve the order, but the behavior is different in some cases.
    For Ex:
    @Prompt('1. Select granularity','A',{'Weekly','Daily','Hourly'},mono,constrained,persistent)
    @Prompt('2. Enter date/time(mm/dd/yyyy hh24:mi:ss)','D',,mono,free,persistent)
    @prompt('3. Select Network View','A','Radio Error\NV Names Path',Mono,constrained,Persistent)
    @Prompt('4. Select BSC Name','A','RE BSC Dim\Ref BSC Name',mono,constrained,persistent)
    @Prompt('Select Time Zone Offset','A','Time Shift\Time Zone Offset',mono,constrained,persistent)
    I expect that the 'Select Time Zone Offset' prompt should come at the end as numeric values have higher priority. But I am getting this in between '3. Select Network View' and '4. Select BSC Name'.
    I don't know why:(
    Even I tried the 'Select Time Zone Offset' prompt message by appending a number like ''5. Select Time Zone Offset'. Then also it is getiing displayed in between 3rd and 4th prompt.
    -Sus.
    Edited by: SUS_India on Apr 21, 2009 10:35 AM

  • Messages get displayed twice

    I've got this global messages entry in my main JSP page that has a bunch of JSTL import in it. That main JSP page has one tag :
    <h:panelGroup id="panelMsg">
           <h:graphicImage width="1" height="10" url="/images/spacer.gif"/>
            <h:messages id="msgRpf" globalOnly="true" styleClass="message"       layout="table"/>
    </h:panelGroup>Whenever there is a message that has to be displayed we do it via a global method in our backingBean and the code is very simple :
    protected void addMessage(String message){
            FacesContext context = FacesContext.getCurrentInstance();
            FacesMessage msg = new FacesMessage(message);
            context.addMessage(null, msg);
      }The problem is if we have to display two messages, instead of beaing added to the first one, another message block gets displayed, hence we have two messages panel displayed with one message each, instead of one panel with two messages in it.
    I tried adding the ID in the context.addMessage method, but it doesn't get displayed...
    Any help or clues would be appreciated
    Thanks
    -Ben

    Maybe more code is needed to help...
    This is part of the main JSP page
      <h:panelGrid id="contenu" columns="2" footerClass="subtitle" headerClass="subtitlebig" styleClass="contenu" columnClasses="subtitle, medium">
        <h:panelGroup id="panelNavigateur">
          <!-- ===== Navigateur -->
          <f:subview id="navigateur">
            <c:import url="navigateur.jsp"/>
          </f:subview>
        </h:panelGroup>
        <h:panelGroup id="panelContenu">
          <h:panelGroup id="panelMenu">
            <!-- ===== menu principal -->
            <f:subview id="menu123">
              <c:import url="gabaritMenu.jsp"/>
            </f:subview>
          </h:panelGroup>
          <!-- ===== sous titre page -->
          <f:facet name="header">
            <h:outputText styleClass="subtitle" value="Sous-Titre de la page"/>
          </f:facet>
          <!-- ===== messages page -->
          <h:panelGroup id="panelMsg">
            <h:graphicImage width="1" height="10" url="/images/spacer.gif"/>
            <h:messages id="msgRpf" globalOnly="true" styleClass="message" layout="table"/>
          </h:panelGroup>
          <!--  ===== formulaire de saisie -->
          <h:panelGroup id="menuH">
            <f:subview id="formSaisie">
              <c:if test="${XmlMenu.page != null}">
                <c:import url="${XmlMenu.page}"/>
              </c:if>
            </f:subview>
          </h:panelGroup>
        </h:panelGroup>
      </h:panelGrid>
    ...If we add 3 messages from our backing bean, instead of adding 3 lines with the corresponding text, 3 different "blocks" of text appear on the page. If I use the .getMessages() and Iterate through the messages, I only see one message instead of the 3 that should be there.
    Any one have a clue ?
    Thanks in advance.
    -Ben

  • Custom error message using MESSAGE Tag

    I am using mulitple input fields in the page and i want to validate them for not empty. If it remains empty then error message should be displayed. This error message is different for every field.
    I've used message tad for this purpose. Is there any way to show the custom message according to our own requriements using this message tag???
    Thank you

    You need to override the default error messages with your own messages properties file which you specify in the faces-config.xml.
    Check this for examples:
    [http://www.jsf-faq.com/faqs/faces-messages.html#126]
    [http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jsf.html#MessageBundleFile]
    For required fields you need to override javax.faces.component.UIInput.REQUIRED.

  • Throw Exception message is displayed twice.

    Hi all,
    In my java class based on a condition, I am throwing an exception. In runtime the exception message is displayed twice. I am sure that my code is gettign executed only once.
    Anyones help is greatly appreciated.
    Thanks in advance
    prabhakar

    Hi all,
    In my java class based on a condition, I am throwing
    an exception. In runtime the exception message is
    displayed twice. I am sure that my code is gettign
    executed only once.
    Anyones help is greatly appreciated.
    Thanks in advance
    prabhakarPlease be a little more explicit about what you're doing, what you expect to happen, and what you actually observe.
    Please post a short, concise, executable example of what you're trying to do. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.
    Post your code between [code] and [/code] tags as described in Formatting Help on the message entry page. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please preview your post when posting code.
    Please assume that we only have the core API. We have no idea what SomeCustomClass is, and neither does our collective compiler.
    Help us help you solve your problem.

  • ADF FACES af:messages only display 1 message

    Hi,
    I'm using the af:messages tag to display warning or error message.
    The problem, is that when I put multiple warning messages in the FacesContext, only one of them is displayed in the message box.
    FacesMessage warning= new FacesMessage(FacesMessage.SEVERITY_WARN, "This is a warning!", "Beware!!!");
    FacesContext.getCurrentInstance().addMessage(null, warning);
    warning= new FacesMessage(FacesMessage.SEVERITY_WARN, "This is another warning!", "Beware even more!!!");
    FacesContext.getCurrentInstance().addMessage(null, warning);In my JSP, I use the <af:messages /> tag without any attributes.
    In this case, only the "This is another warning!" message is displayed.
    Note that if I have multiple error messages, it behave the same.
    I've tried to look in the decompiled code of the renderer (and laf) but I was not able to find out where it retrieve the messages from the FacesContext.
    Using <h:messages layout="table"/> instead of <af:messages /> display the two messages.
    This is with EA9... I did not had a chance to test it with a more recent release of ADF.
    Is this something that is already fixed (if so in which EA) or a known issue?
    Thank's!

    This has been fixed since EA9. It really is time to upgrade!

Maybe you are looking for