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: Mon, 24 Aug 2015 06:51:11 +0200

All examples so far looked like a socket delivering a value. But we all
know, once the communication is established, a potential endless stream
of text or binary data might be transmitted - without affecting the JSF
servlet. All data has to be handled on client side.
Using the chat example, I might want to use a listbox to display the
last 20 entries. We can offer some more abstractions to tell JSF how to
render HTML with invocations of JavaScript.
As a JSF devekoper, I like to get some well defined hooks to add my own
script, e.g.

<socket onreceive="myJavaScriptCall"/>


Herzliche Grüße - Best Regards,

Michael Müller

Read my book "Web Development with Java and JSF": https://leanpub.com/jsf


Am 23.08.2015 um 18:48 schrieb Michael Müller:
>
> 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
>