I use omnifaces and their socket
to implement a one-side web-socket based connection from the server to the client.
I follow their showcase
http://showcase.omnifaces.org/push/socket
http://omnifaces.org/docs/javadoc/3.4/org/omnifaces/cdi/push/Socket.html#ui
<h:form>
<o:socket channel="someChannel" scope="view">
<f:ajax event="someEvent" listener="#{bean.pushed}" render=":foo"
</o:socket>
</h:form>
It's nice that I can do UI updates once a message is received on the frontend. In my case, though, someEvent
is more complex than a String. It's an object
{
"event": "refresh",
"render": "id1 id2"
}
and neither event
not render
attribute is known beforehand.
Is it possible to trigger ajax rendering based on event's message data?
(pseudocode here)
<f:ajax event="<this-event>.event" render="<this-event>.render" />