1 Reply Latest reply on Aug 22, 2013 7:47 PM by Brian Leathem

    Global messages not displaying in jsf2.0

    Balaji S Newbie

      I am not able to dispaly custom error msgs from bean to user using  FacesMessage.

      I am adding msg to addMessage() when user enter mobile no less than 10.

      But on my console I getting msg like below


      INFO  [javax.enterprise.resource.webcontainer.jsf.renderkit] (http-localhost/ WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.

      sourceId=null[severity=(ERROR 2), summary=(mobile no should be greater than 10 degits), detail=()].


      I am using jsf 2.1 , richfaces 4.0 and ,jboss EAP 6.0 servers




      # my Xhtml file


      <!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"








      <link href="../../css/styles.css" rel="stylesheet" type="text/css" />      

      <h:form id="personform12" >

      <h:panelGrid id="test2343" width="80%">

              <rich:messages id="messages" globalOnly="true" errorClass="globalError" showSummary="true" showDetail="false"></rich:messages>




      <h:panelGrid border="0" columns="3" width="90%" cellpadding="0" cellspacing="1" >

      <h:panelGroup styleClass="alignmentRight">


      <h:outputText value="#{bundle['id']}" />


      <h:inputText id="id" value="#{personBean.pdto.id}" required="true">


      <rich:message styleClass="error" for="id" />



          <h:outputText value="#{bundle['name']}" />


      <h:inputText id="name" value="#{personBean.pdto.name}" required="true"/>

      <rich:message styleClass="error" for="name" />


      <h:panelGroup styleClass="alignmentRight">

          <h:outputText value="city" />


      <h:inputText id="city" value="#{personBean.pdto.city}" required="true"/>

      <rich:message styleClass="error" for="city" />


      <h:panelGroup styleClass="alignmentRight">

          <h:outputText value="state" />


      <h:inputText id="state" value="#{personBean.pdto.state}" required="true"/>

      <rich:message styleClass="error" for="state" />


      <h:panelGroup styleClass="alignmentRight">

          <h:outputText value="mobile" />


      <h:inputText id="mobile" value="#{personBean.pdto.mobile}" required="true">


      <rich:message styleClass="error" for="mobile" />



      <h:panelGroup styleClass="alignmentRight">

      <h:outputText value="DOB" />


      <rich:calendar style="height:25px" inputStyle="width:203px" required="true"



                                          id="dob" value="#{personBean.pdto.dob}"

                                          datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" />

      <rich:message styleClass="error" for="dob" />





      <h:commandButton id="commandSubmit" value="Submit" action="#{personBean.save}"></h:commandButton>





      #my jsf bean


      public class PersonJSFBean {


          private static final Logger  log = Logger.getLogger(PersonJSFBean.class);

          private PersonDTO pdto;

          private PersonManager personManager;


           * @return the pdto


          public PersonDTO getPdto() {

              return pdto;



           * @return the personManager


          public PersonManager getPersonManager() {

              return personManager;


          public String save(){

              String str = null;

              try {


                  if(pdto.getMobile().length()<10) {

                      System.out.println("inside the mobile no>>>>>>>>>>>"+pdto.getMobile());

                      FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "mobile no should be greater than 10 degits ", null);

                      FacesContext.getCurrentInstance().addMessage(null, facesMsg);





              } catch (Exception e) {

                  System.out.println("Error occured>>>>>>>>>>>");




              return str;




           * @param pdto the pdto to set


          public void setPdto(PersonDTO pdto) {

              this.pdto = pdto;



           * @param personManager the personManager to set


          public void setPersonManager(PersonManager personManager) {

              this.personManager = personManager;