1 Reply Latest reply on May 7, 2008 3:53 AM by David Radunz

    Exception error handling w- facesMessages - Bug ?

    David Radunz Newbie


        I find myself writing this message in a text editor prior to pasting in the window. Basically I typed up a huge message, went to lunch, had my session expire - went to type a word and was presented with an error page. Not a real 'fault', but sure was annoying!!

        On to the real issue. I posted a question earlier that didn't get any responses at all, so im unsure why that was. I am guessing it's due to the fact that I didn't provide enough information. Feel free to have a read of this here: http://www.seamframework.org/Community/MessageSeverityERRORDoesntWork - What I have found is that the issue is more widespread than just hiding messages that have a severity of error and often they don't appear at all under various scenarios. I am not putting forward the most simple of examples in the hopes that someone can tell me what I am doing wrong.

        Basically put, I wish to add a faces message, throw an exception and then have that message appear on the resulting page for the handled exception. Sounds simple enough yeah? Well it's been anything but simple and this issue has so far dragged on for 3 weeks and I am pretty sure I'm a bit balder than when I started. Below I am going to outline what I have setup and what the results are in the hopes that someone here is able to find the missing piece to my nightmarish puzzle.

      1. I have a simple test page. The test page is not nested in a JDPL page flow (I first incorrectly assumed that may have been part of the picture). The test page as a simple button labeled Boom! to create the scenario as described above. The relevant contents of the page are:

              <h:commandButton value="Boom!" action="#{manageAgentAction.makeBooBoo}"/>

      The contents of the makeBooBoo method are as follows:

          public String makeBooBoo() throws Exception {
              //facesMessages.add(FacesMessage.SEVERITY_ERROR, "facesMessages.add SEVERITY ERROR");
              if (true) {
                  throw new UGAMLSystemErrorException("UGAMLSystemErrorException message");
              return "tooth";

      The pages.xml entry for the test page in question is (and yes, the user is logged in when this occurs):

          <page view-id="/home.xhtml"

      As you can see, the above should simulate the example I want to portray.

      2. I have the following entries in the pages.xml file to handle the above exception:

          <exception class="com.utiba.wt.ugaml.exception.UGAMLSystemErrorException">
              <redirect view-id="/error.xhtml">
                  <message>Ibby Fibby Boo</message>

      And a catch all entry like so:

              <redirect view-id="/error.xhtml">
                  <message>Unexpected error, please try again</message>

      3. The contents of error.xhtml referred to above is as follows:

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          <ui:define name="body">
                  <f:facet name="header">Error(s)</f:facet>
                  <h:outputText value="#{msgHelper.test}"/>

      As you can see, there is also a reference to msgHelper.test. The purpose of this property is to print out the facesMessages present in the environment to see whats actually coming through. The contents of this method is as follows:

          public String getTest() {
              System.out.println("Message Dump ...");
              Iterator<FacesMessage> messages = FacesContext.getCurrentInstance().getMessages(null);
              while (messages.hasNext()) {
                  FacesMessage msg = messages.next();
                  System.out.println("Message: " + msg.getDetail() + " (" + msg.getSeverity() + ")");
              Iterator<FacesMessage> messages2 = FacesContext.getCurrentInstance().getMessages();
              while (messages2.hasNext()) {
                  FacesMessage msg = messages2.next();
                  System.out.println("Message2: " + msg.getDetail() + " (" + msg.getSeverity() + ")");
              return "This is a test";

      4. The result of all this:

        - On the error.xhtml page all I see is This is a test, from the outputText field. No error messages are displayed what so ever.
        - In the console, the following is printed:

      5:20:03,317 INFO  [STDOUT] Message Dump ...
      15:20:03,415 INFO  [STDOUT] Message Dump ...

      As you can tell, NO messages are coming through.

      What I expect to see at the very least is a message saying facesMessages.add that was added in the first method call.

      I am completely clueless as to why this isn't working and suspect strongly that there is a bug in the system that is causing this. Im happy to be proven wrong - hearing any advice at all would be fantastic at this point.

      Thanks for your time,


        • 1. Re: Exception error handling w- facesMessages - Bug ?
          David Radunz Newbie

          I am not sure whether this message will even go through. Yesterday I posted 3 follow ups to this and they were all deleted/lost. I also started a new topic which was also lost with no explanation. Not sure whats going on..

          The discovery I have now come to is that under certain conditions the messages DO appear, but without even changing anything (other than some text in a message) this then stops working. It's almost as if something is loading in a wierd order and thats the cause of the problem. Like when it loads in the correct order it works, when it doesn't it doesn't work.

          Hope someone can help, or at least comment to know this is being read.