gpt4 book ai didi

Primefaces push 和 Wildfly

转载 作者:行者123 更新时间:2023-12-01 03:49:07 25 4
gpt4 key购买 nike

有没有人设法让wildfly 的undertow 与Primefaces push 2.0 一起工作? Wildfly 的原生 websockets (jee7) 本身就很好用。我不确定如何与primefaces 集成。任何示例都会有所帮助。

最佳答案

我在 WildFly 8.1.0.Final 上使用:

pom.xml:

<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>

网页.xml:
<servlet>
<servlet-name>PrimePushServlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>PrimePushServlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

在 .xhtml 中:
<p:socket onMessage="handleMessage" channel="/#{request.remoteUser}" />
<script type="text/javascript">
function handleMessage(facesmessage) {
var msgdetail = $.base64.decode(facesmessage.detail);
facesmessage.detail = msgdetail;
PF('growlWidget').show([ facesmessage ]);
}
</script>

我的资源:
@PushEndpoint("/{user}")
@Singleton
public class UserResource {

@PathParam("user")
private String user;

@OnMessage(encoders = { JSONEncoder.class }, decoders = { JSONDecoder.class })
public FacesMessage onMessage(FacesMessage message) {
return message;
}

应修改 javascript 部分以满足您的需求。

关于Primefaces push 和 Wildfly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24514169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com