Hi,
I just entered the first topic to the eclipse Moharra forum. It's
a moderated forum and thus the message did not appear yet. And
mayby this list is the better place for suggestions?
This is what I posted:
Although a JSF user might use the _javascript_ API to start an ajax
request, most simply use the f:ajax tag. JSF tags usually hide
away HTML and/or _javascript_ stuff, but websocket.
Consider this page excerpt of a definition:
<f:websocket channel="events" _onmessage_="eventListener"
/>
<script type="text/_javascript_">
//<![CDATA[
function eventListener(message, channel, event) {
var element = document.getElementById("activity");
element.innerHTML = message;
}
//]]>
</script>
<h1>
<h:outputLabel value="Last activity: "/>
<h:outputText id="activity" value=""/>
</h1>
The user needs some JS woodoo to handle the message he received
from the server.
I suggest to optionally hide JS by a special "target" attribute:
<f:websocket channel="events" target="activity" />
<h1>
<h:outputLabel value="Last activity: "/>
<h:outputText id="activity" value=""/>
</h1>
If target is declared, than then inner html of the referenced
component will be replaced by the message. If target is declared,
than the user might omit "onmessage". It will be allowed to use
both.
As an additional sugesstion, a "max" attribute can be added to
"target"
<f:websocket channel="events" target="activity"
max="10"/>
If max is not defined, it is treated as one. Max is used to
control how many messages will be added to the target element. If
just on, the inner html will be replaced. If > 1 than the
message will be added. If > max then the first message will be
removed. This is useful for list elements or textareas. In case of
text areas, the message will be added as a new line, removing
lines in front if there are more than max.