jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] Re: [JAVASERVERFACES-SPEC_PUBLIC-1396] f:socket for SSE and WebSocket PROPOSAL

From: Michael Müller <michael.mueller_at_mueller-bruehl.de>
Date: Sun, 23 Aug 2015 18:48:03 +0200

Am 20.08.2015 um 23:11 schrieb Bauke Scholtz:
> Hi,
>
> MM> Thinking of HTML friendly coding, it would be great, to implement it as
> HTML attribute also (same thoughts might be applied to other tags):
> MM>
> MM> <h:inputText ...>
> MM> <f:socket.../>
> MM> </h:inputText>
>
> What exactly would this do?
>
> To me, it would make more sense if it was the other way round as it's push,
> not pull. E.g.
>
> <f:socket>
> <h:outputText value="#{bean.message}" />
> </f:socket>
>
The nature of a WebSocket is bidirectional communincation at any time.
Thus, if data is sent by a server, it always is a push, regardless of
the notation.
But, we have to condider about the communication direction. Imagine a
chat, bound to two different components

a)
<input type="text" jsf:channel="send" id="userInput"/>
<input type="text" jsf:channel="receive" id="chatOutput"/>


b)
<h:inputText id="userInput">
   <f:socket direction="send"/>
</h:inputText>

<h:inputTextarea id="chatOutput">
   <f:socket direction="receive"/>
</h:inputTextarea>

c)
<h:inputText id="userInput">
   <f:socket/>
</h:inputText>
<f:socket>
   <h:inputTextArea id=chatOutput/>
</f:socket>

c) looks very strange to me. As a JSF developer I don't care about a
special notation to distinguish between push or poll. I just want to
connect the communication channel to a component. Maybe, a JSF
implementor needs such a notation?

Send and receive might be bound to just one component

a)
<input type="text" jsf:channel="bidirectional" id="userInput"/>


b)
<h:inputText>
   <f:socket direction="bidirectional"/>
</h:inputText>

And, what happens, if I want to dispatch the data I just received
depending on its content to different UIComponents? I need to receive
the data into a JavaScript Object, which performs the dispatch.

---
@Bauke, a last bunch of questions:
BS><f:socket>
BS>   <h:outputText  value="#{bean.message}" />
BS></f:socket>
I did not understand this notation. I can see the output text nested 
into a socket, but retrieving its data from a property of a bean. How 
should JSF create the connection between the socket and the outputText? 
Is "bean.value" just a dummy, which has to be ignored? Or does it mean 
something like
<f:socket>
   <h:outputText value="#{socket.value}" />
</f:socket>
?
Or am I to stupid to get the real intention?
Cheers,
Michael