Find a solution that works great with the message in Prime face.
Thinking with you, even if you worked with a growl
Here is the solution
There are 2 parameters in add addMessage, the client identifier is UIComponent and FacesMessage. FaceMessage shows or identifies the message, and the identifier of the child element of the component shows where the component is located. Here you skipped the component part. To do this, you must associate the UIComponent with the bean class. So that he can find the Component.
Now do the following:
Define a UIComponent in a bean class
Bind it with the appropriate Button command
and get the identifier from the component in the bean class
Your code should be modified as follows
> private UIComponent component; (...) addMessage(component.getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, "Connection failed.", t.getLocalizedMessage())); (...)
Inside the xhtml file you have to bind UIComponent
<h:form prependId="false"> (...) <h:panelGrid> <f:facet name="footer"> <p:commandButton id="btnTester" value="Tester" actionListener="#{assistantCreationSourcesBean.testerConnexionBase}" update="msgTester" binding="#{assistantCreationSourcesBean.component}"/> <p:message id="msgTester" for="btnTester" /> </f:facet> </h:panelGrid> </h:form>
Now the message will work. !! For me it worked fine :)
Dileep
source share