I have correctly set up a Push server using PrimeFaces p:push component (using a Jetty web server to handle Websockets).
However, the Push mechanism does not work when trying to display an alert upon reception of another thread.
Here some of the code I use:
JSF page firing the asynchronous Web Service call:
<f:view ...>
<pm:page title="TEST">
<p:push onmessage="handleMessage" channel="counter" widgetVar="pushEssaisCounter" autoConnect="true" />
<pm:view id="essais-run">
<h:form prependId="false">
<pm:header title="TEST">
<f:facet name="right">
<pm:commandButton value="Async Call" actionListener="#{AsyncHandler.onRun}" update="erunMessages erunResult" swatch="a" inline="true" icon="check" />
</f:facet>
</pm:header>
<pm:content> ...
Backing bean handling the actionListener and forking on a new thread (AsyncHandler.java):
public void onRun(ActionEvent event) {
Executors.newSingleThreadExecutor().submit(new EssaiCallable());
}
Code executed asynchronously by the new thread (upon reception of the Web Service response):
private class EssaiCallable implements Callable<CreerEssaiS1F2Response> {
@Override
public synchronized CreerEssaiS1F2Response call() throws Exception {
log.info("ASYNC TEST RESPONSE received!");
RequestContext.getCurrentInstance().push("counter", 666);
}
}
I have no exception or error when running this code, but the content is just never pushed 🙁
Am I missing something? Any help would be appreciated, thanks in advance.
Cagatay Civici’s answer from Primefaces Forum ( http://forum.primefaces.org/viewtopic.php?f=3&t=16545 ):
There is also an issue opened:
http://code.google.com/p/primefaces/issues/detail?id=849