<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Can I use PrimePush in Xpert.ivy?</title><link>https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy</link><description>&lt;p&gt;I want to send messages from the Xpert.ivy server to a HTML Dialog, i.e. to JSF pages. &lt;a href="http://www.primefaces.org/showcase/push/"&gt;PrimePush&lt;/a&gt; supports this but is not yet integrated in Xpert.ivy. How can I use it anyways?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 21 Apr 2015 09:08:32 -0400</lastBuildDate><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/1272</link><description>&lt;p&gt;&lt;strong&gt;Answers for Axon.ivy 5.1 (Lauberhorn) with Primefaces 5.0&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See &lt;a href="https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/11"&gt;answers for Xpert.ivy 5.0 (Rothorn) with Primefaces 3.5&lt;/a&gt; if you use an older version.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The usage of PrimePush has changed in many ways since ivy 5.1 as Primefaces has changed its implementation between primefaces 3.5 (ivy 5.0) and primefaces 5.0 (ivy 5.1). The documentation for Primefaces 5.0 with PrimePush is &lt;a href="http://www.primefaces.org/docs/guide/primefaces_user_guide_5_0.pdf#page=526&amp;amp;zoom=auto,56,773"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But basically primefaces push still works. There is an updated demo project here: &lt;a href="/upfiles/PrimePush_51.iar"&gt;PrimePush_51.iar&lt;/a&gt;. It can be set up as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Download the atmospehere-runtime jar (and optionally its sources) from a maven repository: &lt;a href="http://central.maven.org/maven2/org/atmosphere/atmosphere-runtime/2.1.3/atmosphere-runtime-2.1.3.jar"&gt;atomsphere-runtime.jar&lt;/a&gt;. I used the version 2.1.3 that is documented by Primefaces. But I think newer versions should work also.&lt;/li&gt;
&lt;li&gt;Copy the atmosphere JAR into your designer/webapps/ivy/WEB-INF/lib&lt;/li&gt;
&lt;li&gt;Adjust the web.xml in designer/webapps/ivy/WEB-INF/web.xml as documented in the first answer&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;web.xml example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;servlet&amp;gt;
    &amp;lt;servlet-name&amp;gt;Push Servlet&amp;lt;/servlet-name&amp;gt;
    &amp;lt;servlet-class&amp;gt;org.primefaces.push.PushServlet&amp;lt;/servlet-class&amp;gt;
    &amp;lt;async-supported&amp;gt;true&amp;lt;/async-supported&amp;gt;
    &amp;lt;init-param&amp;gt;
        &amp;lt;param-name&amp;gt;org.atmosphere.useWebSocketAndServlet3&amp;lt;/param-name&amp;gt;
        &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
    &amp;lt;/init-param&amp;gt;
&amp;lt;/servlet&amp;gt;
&amp;lt;servlet-mapping&amp;gt;
    &amp;lt;servlet-name&amp;gt;Push Servlet&amp;lt;/servlet-name&amp;gt;
    &amp;lt;url-pattern&amp;gt;/primepush/*&amp;lt;/url-pattern&amp;gt;
&amp;lt;/servlet-mapping&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Write an endpoint bean for your channel. For instance a simple echo bean look like this: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;endpoint example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;package ch.ivyteam.test;

import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.impl.JSONEncoder;

@PushEndpoint("/mychannel")
public class MessageResource {

    @OnMessage(encoders = { JSONEncoder.class })
    public String onMessage(String message) 
    {
        return message;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;copy the resulting .class file with its parent package folders into designer/webapps/ivy/WEB-INF/classes directory. Or copy the existing from the demo.iar/classes_endpoints&lt;/li&gt;
&lt;li&gt;Restart your Designer&lt;/li&gt;
&lt;li&gt;Import the PrimePush_51.iar demo project&lt;/li&gt;
&lt;li&gt;Run the Hello World example.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you still run into problem with atomsphere. It can help to get more log outputs form the atmosphere runtime jar. To do so copy the following xml into your designer/configuration/log4jconfig.xml:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;category name="org.atmosphere.cpr.AtmosphereFramework" class="ch.ivyteam.log.Logger"&amp;gt;
    &amp;lt;priority value="INFO"/&amp;gt;
&amp;lt;/category&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 21 Apr 2015 09:08:32 -0400</pubDate><guid>https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/1272</guid></item><item><title>Answer by Hap Em</title><link>https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/1270</link><description>&lt;p&gt;Hello All,&lt;/p&gt;
&lt;p&gt;I have made a demo to use primepush on Ivy 5.1.4 and atmosphere 2.1.6.
When I started Ivy --&amp;gt; It showed an error:
13:08:34.123 ERROR [org.primefaces.push.PushServlet] [localhost-startStop-1] [] 
  No Annotated class using @PushEndpoint found. Push will not work.&lt;/p&gt;
&lt;p&gt;This is my code:&lt;/p&gt;
&lt;p&gt;xhtml page:
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" &amp;lt;br=""/&amp;gt;      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"&amp;gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;h:head&amp;gt;
    &amp;lt;title&amp;gt;JSF User Dialog&amp;lt;/title&amp;gt;
    &amp;lt;script&amp;gt;
        function onMessage(msg) {
            $('.display').html(msg);
        };
        function onError() {
            alert("error");
        };
    &amp;lt;/script&amp;gt;
&amp;lt;/h:head&amp;gt;
&amp;lt;h:body&amp;gt;
    &amp;lt;h:form&amp;gt;
        &amp;lt;h:outputText id="out" styleClass="ui-widget display" /&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;
        &amp;lt;p:inputText required="true" value="#{data.message}" /&amp;gt;
        &amp;lt;p:commandButton value="Nachricht senden" actionListener="#{logic.SendMessage}" /&amp;gt;
    &amp;lt;/h:form&amp;gt;
    &amp;lt;p:socket channel="/chat" onMessage="onMessage" onMessagePublished="onMessage" transport="websocket" widgetVar="pfsocket" autoConnect="true" fallbackTransport="websocket"/&amp;gt;
&amp;lt;/h:body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;lt;/html&amp;gt;&lt;/p&gt;
&lt;p&gt;In SendMessage event:
JSONObject rs = new JSONObject();
rs.put("pfpd", String.valueOf("Nachricht: " + in.message));&lt;/p&gt;
&lt;p&gt;EventBusFactory.getDefault().eventBus().publish("/chat", rs);&lt;/p&gt;
&lt;p&gt;In web.xml:
&amp;lt;servlet&amp;gt;
        &amp;lt;servlet-name&amp;gt;Push Servlet&amp;lt;/servlet-name&amp;gt;
        &amp;lt;servlet-class&amp;gt;org.primefaces.push.PushServlet&amp;lt;/servlet-class&amp;gt;
        &amp;lt;init-param&amp;gt;
            &amp;lt;param-name&amp;gt;org.atmosphere.cpr.broadcasterCacheClass&amp;lt;/param-name&amp;gt;
            &amp;lt;param-value&amp;gt;org.atmosphere.cache.UUIDBroadcasterCache&amp;lt;/param-value&amp;gt;
        &amp;lt;/init-param&amp;gt;
        &amp;lt;init-param&amp;gt;
            &amp;lt;param-name&amp;gt;org.atmosphere.cpr.broadcasterClass&amp;lt;/param-name&amp;gt;
            &amp;lt;param-value&amp;gt;org.atmosphere.cpr.DefaultBroadcaster&amp;lt;/param-value&amp;gt;
        &amp;lt;/init-param&amp;gt;
        &amp;lt;init-param&amp;gt;
            &amp;lt;param-name&amp;gt;channels&amp;lt;/param-name&amp;gt;
            &amp;lt;param-value&amp;gt;chat&amp;lt;/param-value&amp;gt;
        &amp;lt;/init-param&amp;gt;
        &amp;lt;init-param&amp;gt;
            &amp;lt;param-name&amp;gt;org.atmosphere.useWebSocketAndServlet3&amp;lt;/param-name&amp;gt;
            &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
        &amp;lt;/init-param&amp;gt;
        &amp;lt;init-param&amp;gt;
            &amp;lt;param-name&amp;gt;org.atmosphere.cpr.SessionSupport&amp;lt;/param-name&amp;gt;
            &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
        &amp;lt;/init-param&amp;gt;
        &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;
        &amp;lt;async-supported&amp;gt;true&amp;lt;/async-supported&amp;gt;
    &amp;lt;/servlet&amp;gt;
    &amp;lt;servlet-mapping&amp;gt;
        &amp;lt;servlet-name&amp;gt;Push Servlet&amp;lt;/servlet-name&amp;gt;
        &amp;lt;url-pattern&amp;gt;/primepush/*&amp;lt;/url-pattern&amp;gt;
    &amp;lt;/servlet-mapping&amp;gt;&lt;/p&gt;
&lt;p&gt;When I sent a message to "chat" channels --&amp;gt; It's not working&lt;/p&gt;
&lt;p&gt;Pls help me if you have any idea!
Thanks in advance!
Regards,&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Hap Em</dc:creator><pubDate>Mon, 20 Apr 2015 08:34:26 -0400</pubDate><guid>https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/1270</guid></item><item><title>Answer by SupportIvyTeam</title><link>https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/11</link><description>&lt;p&gt;&lt;strong&gt;Answers for Xpert.ivy 5.0 (Rothorn) with Primefaces 3.5&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See &lt;a href="http://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/1272"&gt;answers for Axon.ivy 5.1 (Lauberhorn) with Primefaces 5.0&lt;/a&gt; if you use an older version.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are two steps to do. First you have to install the &lt;a href="https://github.com/Atmosphere/atmosphere"&gt;Atmosphere framework&lt;/a&gt; on which &lt;a href="http://www.primefaces.org/showcase/push/index.jsf"&gt;PrimePush&lt;/a&gt; is based on. Second you have to configure PrimePush to use it in Xpert.ivy.&lt;/p&gt;
&lt;p&gt;For the first step, Atmosphere unfortunately does not provide binary releases. So, please follow the instructions on the Atmosphere homepage to get the Atmosphere jar files. Then move them into the directory &lt;em&gt;webapps/Ivy/WEB-INF/lib&lt;/em&gt; of the Designer/Server.&lt;/p&gt;
&lt;p&gt;For the second step, please open the file &lt;em&gt;webapps/Ivy/WEB_INF/web.xml&lt;/em&gt;. Within the web-app tag, add the following text:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;servlet&amp;gt;
    &amp;lt;servlet-name&amp;gt;Push Servlet&amp;lt;/servlet-name&amp;gt;
    &amp;lt;servlet-class&amp;gt;org.primefaces.push.PushServlet&amp;lt;/servlet-class&amp;gt;
    &amp;lt;async-supported&amp;gt;true&amp;lt;/async-supported&amp;gt;
    &amp;lt;init-param&amp;gt;
        &amp;lt;param-name&amp;gt;org.atmosphere.useWebSocketAndServlet3&amp;lt;/param-name&amp;gt;
        &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
    &amp;lt;/init-param&amp;gt;
&amp;lt;/servlet&amp;gt;
&amp;lt;servlet-mapping&amp;gt;
    &amp;lt;servlet-name&amp;gt;Push Servlet&amp;lt;/servlet-name&amp;gt;
    &amp;lt;url-pattern&amp;gt;/primepush/*&amp;lt;/url-pattern&amp;gt;
&amp;lt;/servlet-mapping&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Re-start the Designer/Server. To check whether it works not, please use the &lt;a href="http://xpert-ivy-hacker-source-code.googlecode.com/svn/trunk/PrimePush"&gt;example project&lt;/a&gt; from the &lt;a href="http://blog.xpertivyhacker.ch/"&gt;Xpert.ivy Hacker&lt;/a&gt;. Start the process &lt;em&gt;PrimePush Hello World&lt;/em&gt;  in multiple browsers and type a message in one of the browsers. If everything is correct you should see the message posted to all browser windows. &lt;/p&gt;
&lt;p&gt;&lt;br&gt;
&lt;br&gt;
Note: This question and answer was &lt;a href="http://blog.xpertivyhacker.ch/2012/11/xpertivy-primepush-installieren.html"&gt;originally posted&lt;/a&gt; by Heinrich Spreiter on his &lt;a href="http://blog.xpertivyhacker.ch/"&gt;Xpert.ivy Hacker blog&lt;/a&gt;. Many thanks to Henry for his enthusiastic work. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">SupportIvyTeam</dc:creator><pubDate>Mon, 07 Oct 2013 13:42:01 -0400</pubDate><guid>https://answers.axonivy.com/questions/10/can-i-use-primepush-in-xpert-ivy/11</guid></item></channel></rss>