I am trying to conditionally display a PrimeFaces message but it is not working. My controller PostConstruct method looks like this:
@ManagedBean
@ViewScoped
public class DIGRCController {
private DIGRC digrc;
private DIGRCService service;
//getters and setters
@PostConstruct
public void init() {
digrc = new DIGRC();
service = new DIGRCService();
if(digrc.getIsValueSet())
{
FacesContext.getCurrentInstance().addMessage(
"messages",
new FacesMessage(FacesMessage.SEVERITY_WARN, "Warning!", "ERROR! Can't updated."));
}
}
}
If some condition is met after constructing the bean, I want to display a warning message on top of my form. My view looks like this:
<h:form id="mainForm">
<p:messages for="messages" autoUpdate="true" />
<!-- other content -->
</h:form>
The condition in place is been met (I tested that) but the message is not been displayed. Why is this happening?
I am using PrimeFaces 5.3 and JSF 2.2.