1 Reply Latest reply on Apr 22, 2009 6:14 PM by mwohlf

    rich:messages or h:messages and javascript call

      Hello all!

      I currently have a Seam project with one XHTML page. This page contains several forms, each containing several controls. I need a way of displaying global error messages, but not by having to necessarily reRender the surrounding form (if this has to be done then so be it, it's just a case of updating all of the controls at the moment).

      When the error messages are displayed, rather than have a plain unordered list appear wherever I put the <h:messages> tag, I have been investigating wrapping this in a jQuery dialog, or some sort of jQuery plugin to customise the layout (perhaps a yellow bar at the top of the window, like IE does?). However, this requires a Javascript call to initiate the jQuery item, which I can see no way of doing.

      Does anybody have any suggestions?

      Cheers,

      Chris
        • 1. Re: rich:messages or h:messages and javascript call
          mwohlf

          Hi Chris,


          that's on my feature list too and i just hacked something together, here is what I got so far:



            <a4j:outputPanel id="msgs" ajaxRendered="true">
                <script type="text/javascript">
                  
                     jQuery(document).ready(function() {
                       // change the message properties
                       jQuery('#msgs .messages').css({
                             position: "absolute",
                             top: 0, left: 0, border: 0, padding: 0, margin: 0,
                             width: "100%", background: "#ffff00"  }).show();
                       // hide message after timeout
                       window.setTimeout(function() {
                          jQuery('#msgs .messages').hide();
                       }, 5000);
                     });
                  
                </script>
                <h:messages layout="list" styleClass="messages" style="display: none;"
                            infoClass="info" warnClass="warn" errorClass="error" fatalClass="fatal"
                            escape="false">
                </h:messages>
            </a4j:outputPanel>
          




          I use the jQuery(document).ready() function to change the message's css styles, for ajax requests I rerender the whole msgs panel including the javascript part, at least on FF this seems to trigger the jQuery call, haven't tested on other browsers and it seems like a bit of an overkill to me now, hopefully you can do some improvements ;-)