7 Replies Latest reply on Nov 7, 2011 2:02 PM by Brian Leathem

    myFaces and Richfaces 4, FacesMessage not showing

    jordicano Newbie

      Hi,

       

      I've found what it looks to be a weird behaviour with FacesMessages when using a template in RF4.

       

      If I don't use a template the messages appear as they should, but when I use a template they don't and this other message shows on the server console:

       

      16/08/2011 18:19:06 org.apache.myfaces.lifecycle.RenderResponseExecutor execute

      WARNING: There are some unhandled FacesMessages, this means not every FacesMessage had a chance to be rendered.

      These unhandled FacesMessages are:

      - This is a FacesMessage

       

       

      This is the source code:

       

      TestFacesMessage.xhtml

       

      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" 
          xmlns:h="http://java.sun.com/jsf/html" 
          xmlns:ui="http://java.sun.com/jsf/facelets" 
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich">
      
          <ui:composition template="simpleTemplate.xhtml">
              <ui:define name="content">    
                  <h:form id="myForm">
                      <rich:messages/>
                      <a4j:commandButton value="Show message" actionListener="#{testFacesMessage.showMessage}"/>
                      <h:commandButton value="Hide message">
                          <f:ajax event="click" render="myForm" execute="@none"/>
                      </h:commandButton>
                  </h:form>
              </ui:define>
          </ui:composition>
      </html>
      

       

      This is the method which adds a FacesMessage to FacesContext:

       

      public class TestFacesMessage {
          
          public void showMessage() {
              FacesContext fcsContext = FacesContext.getCurrentInstance();
              FacesMessage msg = new FacesMessage("This is a FacesMessage");
              msg.setSeverity(FacesMessage.SEVERITY_ERROR);
              fcsContext.addMessage(null,msg);    
          }
      
      }
      

       

       

      simpleTemplate.xhtml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core" 
              xmlns:ui="http://java.sun.com/jsf/facelets">
             
          <h:head>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              <title>
                  <ui:insert  name="title" >Default Title</ui:insert>
              </title>
              <style type="text/css">
                  body {
                    font-family: Verdana, Arial, Helvetica, sans-serif;
                    font-size: small;
                  }
                  hr {
                      margin: 0px;
                      color: gray;
                  }
              </style>
          </h:head>
      
          <h:body>
              <ui:insert name="content">
                  <h:outputText value="Default body" />
              </ui:insert>
          </h:body>
      
      </html>
      

       

      Any help would be appreciated.

        • 1. Re: rich:messages and templates in RF4
          jordicano Newbie

          I've been testing under different environments and it seems to work using myFaces 2.0.5, and not work with versions 2.0.6, 2.0.7 and 2.1.1.

           

          If we subtitute all richfaces components (<rich:messages>, <h:commandButton>, etc) it works flawlessly, no matter which version is used, so it must be a Richfaces issue (tested on 4.0 and 4.1.0 M1).

           

          This works:

           

          <?xml version="1.0" encoding="UTF-8" ?>
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml" 
              xmlns:h="http://java.sun.com/jsf/html" 
              xmlns:ui="http://java.sun.com/jsf/facelets" 
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich">
          
              <ui:composition template="simpleTemplate.xhtml">
                  <ui:define name="content">    
                      <h:form id="myForm">
                          <h:messages/>
                          <h:commandButton value="Show message" actionListener="#{testFacesMessage.showMessage}"/>
                          <h:commandButton value="Hide message">
                              <f:ajax event="click" render="myForm" execute="@none"/>
                          </h:commandButton>
                      </h:form>
                  </ui:define>
              </ui:composition>
          </html>
          

           

          This doesn't:

           

          <?xml version="1.0" encoding="UTF-8" ?>
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml" 
              xmlns:h="http://java.sun.com/jsf/html" 
              xmlns:ui="http://java.sun.com/jsf/facelets" 
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich">
          
              <ui:composition template="simpleTemplate.xhtml">
                  <ui:define name="content">    
                      <h:form id="myForm">
                          <h:messages/>
                          <a4j:commandButton value="Show message" actionListener="#{testFacesMessage.showMessage}"/>
                          <h:commandButton value="Hide message">
                              <f:ajax event="click" render="myForm" execute="@none"/>
                          </h:commandButton>
                      </h:form>
                  </ui:define>
              </ui:composition>
          </html>
          
          • 2. Re: rich:messages and templates in RF4
            Brian Leathem Master

            We're seeing a lot of issues with MyFaces throughout the RichFaces 4.1 development process.  Many of them already have jira issues, but please file any new issues that you think have not already been reported.

            • 4. Re: myFaces and Richfaces 4, FacesMessage not showing
              jordicano Newbie

              Seems the resolution for this issue has been postponed till 4.2.0.Tracking

              Any news on this?

              We need to show FacesMessage in order to report validation errors to users, it is key for our application.

              • 5. Re: myFaces and Richfaces 4, FacesMessage not showing
                Brian Leathem Master

                We'll be diving into the RichFaces/MyFaces issues in 4.2 -- 4.1 is focusing on Mojarra compatibility.  It's an unfortunate compromise, but the best we could do to ensure we get 4.1 out in a timely manner.

                • 6. Re: myFaces and Richfaces 4, FacesMessage not showing
                  jordicano Newbie

                  Should we use Mojarra then?

                  What's your main development platform? Mojarra + Tomcat? Which versions?

                  We use RichFaces extensively so it would be probably better if we use the same platform you're focusing on.

                  • 7. Re: myFaces and Richfaces 4, FacesMessage not showing
                    Brian Leathem Master

                    While we aim to be compatible with as many platforms as possible, at the moment we tend to work mostly with JBoss AS7, and Tomcat + Mojarra 2.1.x.  I want to re-iterate that MyFaces compatibility is important to us, and something we will re-visit once we get 4.1 out the door.