1

The PrimeFaces pdf says that websockets with server push is only available with Jetty but Glassfish3.1 does have a websockets component with grizzly. Is the documentation wrong? has anyone used these two for push with websockets? How was this done?

Randnum
  • 1,360
  • 4
  • 32
  • 48

1 Answers1

4

The PrimeFaces Users Guide documentation is right. Note that it's literally telling that the push servlet has to run in a different application than the JSF2 application itself.

6.1 Setup

Push Server

PrimeFaces Push uses a servlet as a dispatcher. This servlet should be in a different application than the JSF application and at the moment can only be deployed on jetty server.

So the Jetty-only support should be a non-issue. You can just keep running your JSF2 webapp in Glassfish. You just have to setup and run Jetty side by side on a different port if you have only one server machine.

The reason is most likely because the websockets are not supported by standard Servlet API spec (it's however planned for the upcoming Servlet 3.1). With Servlet 3.0 and older, you would need container specific code and libraries. It's for PrimeFaces likely not worth the effort to ship the container specific code and libraries for a wide range of existing servletcontainers along with the PrimeFaces JAR.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks, do you know of a rich component framework for JSF that would allow me to use Glassfish's websocket api for push? – Randnum Jan 12 '12 at 18:56
  • 1
    I have no idea, I never looked closely at JSF push frameworks. I can however tell that [ICEpush](http://www.icepush.org/) from [ICEfaces](http://www.icefaces.org/main/ajax-java/ajaxpush.iface) is often praised as the best JSF ajax push API. It also seems to be cross-server compatible. – BalusC Jan 12 '12 at 19:00
  • Thanks, I supposed I wouldn't have to use the components framework for push if there were a way to do it directly from glassfish to JSF. Which is really all I need. – Randnum Jan 12 '12 at 19:02
  • If all you want is JSF+Glassfish+Push, you could also homegrow a JSF component with GF 3.1 native API. – BalusC Jan 12 '12 at 19:03
  • Couldn't I just create a socket connection in GF 3.1 then write a small javascript websocket connetor on the client end JSF page? I think that would be a simpler solution. I could probably do all of that in the middle of my JSF + PrimeFaces structure. – Randnum Jan 12 '12 at 19:17
  • 1
    You can do so if you don't want to involve anything form the JSF context/lifecycle. You can find an example here http://weblogs.java.net/blog/spericas/archive/2010/10/14/more-web-sockets-and-html5-glassfish – BalusC Jan 12 '12 at 19:18
  • Not sure what all the consequences of going outside of the JSF context/lifecycle would be yet but it might be something I try. All my application has ot be is a single page with a scroll box that receives text from a server and displays them as they are presented. – Randnum Jan 12 '12 at 19:30
  • There is a push dispatcher servlet coming soon for glassfish from PrimeFaces Push. Still you have other alternatives with or without JSF. Also take a look at atmosphere framework. – Cagatay Civici Jan 13 '12 at 17:21
  • could I use atmosphere with primefaces? – Randnum Jan 13 '12 at 17:40
  • Not sure, but Atmosphere used to be part of the `` component in previous PrimeFaces 2.x version, but it was not exactly easy to configure and run and not always stable. – BalusC Jan 13 '12 at 17:43
  • @CagatayCivici hurry up with that Glassfish dispatcher Cag. Let me knwo if you need some help. – Randnum Jan 13 '12 at 19:24