0

I need your assistant in showing primefaces message on page load once a condition is met. In the case which I am describing, I need to show the primefaces message once the page loads and the flag equals to "Y". With the current code, nothing is showing once the flag equals to "Y". Here is the jsf page code:

 <h:form id="form">
    <div id="msg">
        <p:messages id="messages" showDetail="true" autoUpdate="true" closable="false">
            <p:effect type="pulsate" event="load" delay="500"/>
         </p:messages>
     </div>
</h:form>

And here is the java code:

@PostConstruct
public void init() throws SQLException {

    String error_Flag = "";
    String error_Message = "Failed";
    //select statement
    //error flag
    try {
        //select statement
        //return error flag from SQL statement
        if (error_Flag.equals("Y")) {
            FacesContext.getCurrentInstance().addMessage(null, new

                    FacesMessage(FacesMessage.SEVERITY_ERROR, errorMessage, ""));


            RequestContext context5 = RequestContext.getCurrentInstance();

            context5.update("form:messages"); // I tried :form:messages but failed
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
99maas
  • 1,239
  • 12
  • 34
  • 59

0 Answers0