使用GlassFish 4.0推送Primefaces

时间:2013-09-12 11:24:10

标签: jsf-2 primefaces atmosphere glassfish-4

有没有人成功使用上述配置?我试图使用从primefaces咆哮的推动。我正在使用primefaces 3.5 GlassFish 4.0和Atmosphere 2.0.0.RC5我的配置如下:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

Bean方法:

private void assaginTreatment()
  {
    ...
    PushContext pushContext = PushContextFactory.getDefault().getPushContext();
    pushContext.push("/notifications", facesMsg);
    return;
  }

最后是xhtml文件:

 <p:growl widgetVar="growl" showDetail="true" sticky="true" globalOnly="true" autoUpdate="true" />
            <p:socket onMessage="handleMessage" channel="/notifications" autoConnect="true"/>
            <script type="text/javascript">
                function handleMessage(facesmessage) {
                    facesmessage.severity = 'info';
                    PF('growl').show([facesmessage]);
                }
            </script>

我得到的错误是:

SEVERE: [http-listener-1(4)] WARN org.atmosphere.cpr.MetaBroadcaster - No Broadcaster match /notifications. Message...

1 个答案:

答案 0 :(得分:5)

Atmosphere-2.0.0.RC5,Primefaces-4.0.RC1

我设法做了一个不太好的解决方法,但推动所有人,使它工作。可能对你的用例来说足够了

pushContext.push("/*", facesMsg);

编辑: 所以我做了一些进一步的调试,并增加了一些日志记录

if (BroadcasterFactory.getDefault() != null) {
    Collection<Broadcaster> list = BroadcasterFactory.getDefault().lookupAll();
    for (Broadcaster b : list) {
        logger.warn("id={}", b.getID() );
    }
}

输出:

Info: 2013-09-17 22:43:10,010 - id=/*
Info: 2013-09-17 22:43:10,010 - id=/notificationsprimepush

所以最后我尝试了:

pushContext.push("/notifications" + "primepush", facesMsg);

工作! :)