im currently creating a litte application with spring boot and primefaces and have the problem, that i cant create a error message in my website if there went something wrong. Here some code of the xhtml:
<h:form id="form">
<p:growl id="msgs" showDetail="true"/>
...
<p:commandButton id="btnStartManualCopy" styleClass="pollUpdate" async="true" value="Start" disabled="#{daqScriptController.isProcessing()}" action="#{daqScriptController.startManualCopy}" />
</h:form>
note that async is true so the page does not block while the called method 'startManualCopy' is processing.
inside the method 'startManualCopy' i also handle errors if there are any while processing and want to display specified messaged on the page - within the growl.
What i have tried so far:
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error:", "Some cool text); FacesContext.getCurrentInstance().addMessage(null, msg);
or:
PrimeFacesContext.getCurrentInstance().addMessage(null, msg);
PrimeFaces.current().ajax().update(":msgs");
or:
final RequestContext context = RequestContext.getCurrentInstance();
context.update(":msgs");
note: i tried for the ids some other combinations like :form:msgs and so on - so i can be sure that the right component is adressed. but in the network observer the response never really had an update inside.
what i found out while debugging was, that the responewriter is null in the facescontext inside the async called method. i added a listener, which adds a message to the growl on a tabclose event and this works just fine.
public void onTabClose(TabCloseEvent event) {
FacesMessage msg = new FacesMessage("Tab Closed", "Closed tab: " + event.getTab().getTitle());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
so any idea how i can display the error messages from my usecase?
thanks