Implementing chat in my JSF page - jsf

I have J2EE web application which uses JSF framework. Now I am trying to add chat functionality to my application. The problem that I am facing is
When someone pings me, i should be able to see a chat notification on my jsp page. Which means server should be able to update my page when new chat notification comes. Please tell me how can my jsp page listen to incoming packets.

You should look into push technologies. Many JSF libraries support it directly: icefaces, richfaces and primefaces at least. If you don't want to use any of these you may also check out atmosphere, but this will require some javascript and server side coding.

Related

Mobile JSF how to start in Netbeans?

I would like to write a simple, hello world page in JSF as well as for mobiles and ordinary web pages. Found this: http://mobiforge.com/book/mobile-jsf but seems to be outdated. I cant even download the plugin which is mentioned there (download is unavailable, 404).
I searched Internet and it seems that theres no simple step by step tutorial for writing mobile JSF pages. Any ideas where and how can I start?
Maybe it can help you to use a mobile component framework like PrimeFaces Mobile or IceMobile.
There are some tutorials which describe how to build mobile websites with JSF and PrimeFaces Mobile:
Create Mobile Websites using Java Server Faces and PrimeFaces Mobile
Primefaces Mobile - Weather App Example
PrimeFaces tutorial
PrimeFaces Mobile User Guide
Here are some tutorials about IceMobile:
ICEmobile Tutorials & Samples
Just add mobility: JSF and JSP with ICEmobile
If you don't want to use a mobile JSF component framework you can search the web for the tutorials about combining mobile JavaScript frameworks like jQuery Mobile or Bootstrap with JSF.

can i use a gwt library in a jsf project

I want to create a mobile app using PrimeFaces. In it, I also want to use Phonegap, but not directly, rather through its GWT abstraction- phonegap-gwt.
Some of the features provided by PhoneGap, in a phonegap application, require the web page accessing the phone's functionality to be a local page(on the device where phone's functionality is to be accessed)... this can be done using phonegap-gwt in a google web toolkit project also, i.e. dont put server side code in the page that utilises phonegap-gwt code(correct me if I am wrong here, so far?)... On the other hand, the program created by jsf(i.e. primefaces) is a mobile web application.
Hence, what I am confused about is, can I keep GWT code (for Phonegap access through GWT) and JSF code in the same project? I understand that the phonegap gwt code will get compiled into Javascript, but can such programming,i.e. keeping gwt code with jsf code, be implemented? Even if this is possible theoretically, wont there be issues/restrictions that I would have to keep track of? What are those restrictions? Have you tried combining GWT code with JSF code? Did it work?

JSF and Phonegap

I am a new Java developer and I would like to develop a JSF mobile application. I know I could use JSF 2.0 together with Richfaces, IceFaces or PrimeFaces to develop my app, but I think it would run only on the server and I am not sure if it would have access to offline storage and device’s camera, required by the application.
Question: is it possible to use Phonegap or a similar framework to make my JSF mobile app go native?
I don't think JSF and phonegap can be used together. Phonegap's app is HTML/CSS/javascript app, which doesn't require server. It is client only. JSF app is client-server: application logic mostly located on server and all html generated by server. You can't port it to phone now.
If you need access phone's stuff: offline storage, camera, you can create app in phonegap, sends ajax request to your server. Server can provide some API and you can write it in java. You don't need JSF in this case. Google for REST and Spring for java web services. Or better check this question: https://stackoverflow.com/questions/1710199/which-is-the-best-java-rest-api-restlet-or-jersey
You might want to look at Primeface Mobile. It is a UI toolkit for writing JSF web applications tailored for mobile clients.
http://www.primefaces.org/showcase-labs/mobile/index.jsf

Successful use of websockets with Glassfish and a rich component interface

Has anyone successfully implmented a Glassfish 3.1 server with websockets and a rich component interface for JSF like RichFaces, IceFaces, PrimeFaces. And If so what is the easiest method or best way to do this? Primefaces requires Jetty, and I think IceFaces uses JMS.
I'm just trying to find a way to add server push from Glassfish to my view that will display a text stream as it is available in the client. I'd like to do this through a component UI of JSF but if it's possible to circumvent the framework while still being able to use it for it's javascript management and UI utilities that would work too.
GlassFish 3.1 is broken in terms of WebSocket implementation and support a really old version of the protocol. I recommend you try the 3.1.2 version. If you want to be "shielded" from Websocket/Glassfish changes, take a look at the Atmosphere Framework. The framework take care of all those change.
-- Jeanfrancois
why not using IceFaces for that? I do not know what does it use internally, but they have ServerPush. The library that is doing this is called IcePush. IceFaces are integrated with IcePush.
See http://wiki.icefaces.org/display/ICE/Ajax+Push+-+Overview
AFAIK now they are using long polling, but I hope they will switch to web socket as soon as it will be ready for enterprice.

(inter portlet communication) IPC in liferay 6.0.5 and JSF1.2

We are trying to implement a portlet communication that will be able to simulate the classical redirect, but without success for now.
This looks to be a common question in the portlet world, but there is a lack of documentation/howtos/tutorials on specific portal implementations.
Does anyone have a positive experience achieving portlet communication in this environment:
- liferay 6.0.5
- JSF1.2 - richfaces 3.3.x implementation
IPC Public render parameters get passed to other portlets in the RENDER phase, IPC events get sent in the ACTION phase and passed to the other portlets in the EVENT phase. If you use JSF and don't reload the page then neither of these are possible so Portlet communication via IPC is not an option.
It is however possible to have them communicate using Javascript purely on the client side. The responsible way to manage this is to get each JS library to use the portlet namespace to prevent method and variable collision, but in a controlled environment (ie when you write all custom portlets running on the Portal server) you can omit this.
The other way is to have all communicating portlets to use the Portal server as a middleware container, and they all have to write data to the server and get updates by polling the server. This is not as clean or easy as talking JS to each other directly on the client.

Resources