i have a managed bean with a method that add a message like this:
@ManagedBean
@ViewScoped
public class FileMB implements Serializable{
private static final long serialVersionUID = -2843716026642626725L;
private UploadedFile file;
private boolean enabled = false;
public UploadedFile getFile() {
return file;
}
public void setFile(UploadedFile file) {
this.file = file;
}
public void upload() {
FacesMessage message = new FacesMessage("test");
FacesContext.getCurrentInstance().addMessage(null, message);
}
i call this method from xhtml:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title></title>
</h:head>
<h:body>
<h:form>
<p:commandButton value="Show" type="button" actionListener="#{fileMB.upload}" />
</h:form>
<h:form id="frmMensajes">
<p:messages id="mensajes" showDetails="false"/>
</h:form>
</h:body>
</html>
but i cant see the "test" message, i added the managed bean declaration in faces-config too, what could i do?
Try to add autoUpdate
attribute.
Something like this : <p:messages id="mensajes" showDetails="false" autoUpdate="true" />
According to the documentation :
When auto update is enabled, messages component is updated with each ajax request automatically