我正在使用primefaces 5.3运行Glassfish 4,EclipseLink 2.5。当我将事件发布到primefaces事件总线并尝试更新我的datagrid组件时,它将在提交浏览器中更新,但在单独的会话(第二个用户)中,更新失败,我在浏览器控制台中看到以下错误:
WebSocket connection to 'ws://localhost:8080/myapp/primepush/notify?X-
Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.12-javascript&
X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&
X-atmo-protocol=true' failed: Error during WebSocket handshake:
Unexpected response code: 200
push.js.xhtml?ln=primefaces&v=5.3:1 Websocket closed, reason:
Connection was closed abnormally
(that is, with no close frame being sent). - wasClean: false
我也看到服务器上抛出此异常:
Warning: StandardWrapperValve[Push Servlet]:
Servlet.service() for servlet Push Servlet threw exception
java.io.IOException:
java.util.concurrent.TimeoutException
我通过这样做解雇了这个事件:
EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/notify", "price");
EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/notify", "order");
然后我在javascript中处理这些并通过remotecommand更新:
<script type="text/javascript">
function handleMessage(data)
{
console.log("handle message fired")
console.log(data);
if(data == 'order')
{
console.log("data is order");
checkOrders();
}
if(data == 'price')
{
console.log("data is price");
updateWidget();
updateBalance();
}
}
</script>
<p:remoteCommand name="updateWidget"
actionListener="#{parliamentManager.findLatestPrices}"
update="prices"
autoRun="true"/>
<p:remoteCommand name="updateBalance"
actionListener="#{parliamentManager.findTraders}"
update="balance"
autoRun="true"/>
<p:remoteCommand name="checkOrders"
actionListener="#{parliamentManager.checkOrders}" />
</h:form>
<p:socket onMessage="handleMessage" channel="/notify" />
这是我的datagrid组件:
<h:panelGroup id="resultDisplay">
<p:dataGrid id="prices" var="orderBooks" value=
"#{parliamentManager.latestPricesResults}" columns="3" rows="12">
<p:column>
<p:panel header="#{orderBooks.bidOrderId.member.memberId}">
<h:panelGrid columns="1">
<h:outputText value="#{orderBooks.price}" />
</h:panelGrid>
</p:panel>
</p:column>
</p:dataGrid>
要返回我的开头段落,为什么我对datagrid组件的更新在提交浏览器中成功,但在另一个示例中更新失败,我看到错误消息?
答案 0 :(得分:0)
我通过将我的Glassfish版本更新为4.1.1(版本1)解决了这个问题,原始版本已经很老了(2014)。