当从 DOM 中删除时,JSF WebSocket 的客户端行为是什么
What is the client-side behavior of a JSF WebSocket when it is removed from the DOM
我有几个面板,每个面板显示一些内容,可以显示零个、一个或多个面板,如下例所示:
<div jsf:id="contents">
<ui:fragment rendered="#{aContent.rendered}">
<h:form>
<o:socket channel="a-channel" onmessage"onAMessage"/>
<o:commandScript name="onAMessage"
actionListener=#{aContent.update()}"
render=":aComponent"/>
</h:form>
<my:aComponent id="aComponent" />
</ui:fragment>
<ui:fragment rendered="#{bContent.rendered}">
<h:form>
<o:socket channel="b-channel" onmessage"onBMessage"/>
<o:commandScript name="onBMessage"
actionListener=#{bContent.update()}"
render=":bComponent"/>
</h:form>
<my:bComponent id="bComponent" />
</ui:fragment>
</div>
我想知道在对封闭元素进行 AJAX 更新后从 DOM 中删除其中一个 UI 片段时,客户端 Web 套接字会发生什么情况。
网络套接字是否关闭?
我应该考虑另一种方法吗?
根据目前的实施方式,它将保留 运行。您需要在 connected
属性中重复条件。
<ui:fragment rendered="#{aContent.rendered}">
<o:socket ... connected="#{aContent.rendered}" />
当我计划添加 <f:ajax>
对 <o:socket>
的支持时,也许这会在稍后得到改进。
另一方面,您的代码片段不是文档的 DRY. Try restricting to only 1 socket+commandScript combination which does its job dynamically based on contents of the pushed message. See also Channel design hints 部分。
我有几个面板,每个面板显示一些内容,可以显示零个、一个或多个面板,如下例所示:
<div jsf:id="contents">
<ui:fragment rendered="#{aContent.rendered}">
<h:form>
<o:socket channel="a-channel" onmessage"onAMessage"/>
<o:commandScript name="onAMessage"
actionListener=#{aContent.update()}"
render=":aComponent"/>
</h:form>
<my:aComponent id="aComponent" />
</ui:fragment>
<ui:fragment rendered="#{bContent.rendered}">
<h:form>
<o:socket channel="b-channel" onmessage"onBMessage"/>
<o:commandScript name="onBMessage"
actionListener=#{bContent.update()}"
render=":bComponent"/>
</h:form>
<my:bComponent id="bComponent" />
</ui:fragment>
</div>
我想知道在对封闭元素进行 AJAX 更新后从 DOM 中删除其中一个 UI 片段时,客户端 Web 套接字会发生什么情况。
网络套接字是否关闭? 我应该考虑另一种方法吗?
根据目前的实施方式,它将保留 运行。您需要在 connected
属性中重复条件。
<ui:fragment rendered="#{aContent.rendered}">
<o:socket ... connected="#{aContent.rendered}" />
当我计划添加 <f:ajax>
对 <o:socket>
的支持时,也许这会在稍后得到改进。
另一方面,您的代码片段不是文档的 DRY. Try restricting to only 1 socket+commandScript combination which does its job dynamically based on contents of the pushed message. See also Channel design hints 部分。