How to solve “p:message not working” in Primefaces? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to solve “p:message not working” in Primefaces? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m building a form that let the user enter database connection parameters. Once the parameters are typed the user can test (btnTester) if connection can be established with its parameters.

In all cases, a message is produced for the user. Here the example of a failed connection attempt from backing bean code :

(...)
addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Connection failed.", t.getLocalizedMessage()));
(...)

Here is the form code. I’d like the message to appear in a p:message. Unfortunately, nothing happen. No message (connection successful or not) is displayed after the button : Even with the global attribute set to false or true.

<h:form prependId="false">
(...)
  <h:panelGrid>                 
    <!-- Other form components here -->
    <f:facet name="footer">
      <p:commandButton
          id="btnTester"
          value="Tester"
          actionListener="#{assistantCreationSourcesBean.testerConnexionBase}"
          update="msgTester" />
          <p:message id="msgTester" for="btnTester" />
    </f:facet>
 </h:panelGrid>
</h:form>

What am I missing ?

Answer

I use a growl instead of a message for solving my problem.

We are here to answer your question about How to solve “p:message not working” in Primefaces? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji