由于不推荐使用 Primefaces 推送,我想使用 f:websocket 更改为 JSF 2.3。
因此我在我的 xhtml 中添加了一个 websocket:
<h:form>
<f:websocket channel="testChannel" onmessage="socketListener" />
<h:outputScript>
function socketListener(message, channel, event) {
console.log(message);
}
</h:outputScript>
</h:form>
我添加了一个 Bean 来发送推送:
@Named("PushTestBean")
@ApplicationScoped
public class TestPush {
@Inject
@Push(channel = "testChannel")
private PushContext push;
public void test() {
push.send("test");
}
}
在我的 web.xml 中,我有:
<context-param>
<param-name>javax.faces.ENABLE_WEBSOCKET_ENDPOINT</param-name>
<param-value>true</param-value>
</context-param>
我将描述的 jsf 2.3 jar 添加到我的 wildfly 11.0.0 服务器。编译和部署工作没有任何问题。但是,当我使用套接字导航到页面时,出现异常:
2018-02-15 22:41:48,224 ERROR [de.digitaljukebox.web.exceptionHandler.CustomExceptionHandler] (default task-96) Error while rendering view: javax.faces.application.ViewHandler.getWebsocketURL(Ljavax/faces/context/FacesContext;Ljava/lang/String;)Ljava/lang/String;