« Indietro

node.js with Liferay 6.1

Company Blogs 7 marzo 2012 Da David Truong Staff

Wow, it's been a while since I last posted.  Liferay 6.1 EE has just been released and it's changed so much!  I decided to build a node.js app that calls Liferay using the improved JSON web services.  Really, I think this could work just as easily with 6.0 but whatever.  The project currently grabs the layouts of the Guest community and displays the portlets as widgets and using bootstrap for default styling.  

There's no reason for this project but I did it just to do it so it's more of a hacked together project but here it is for anyone interested in improving it or playing with it:


You will need a liferay 6.1 server running on 8080 using test@liferay.com/test.

Potential use cases:

  • Write a mobile site
  • Write a new frontend 
  • Integrate Liferay with another node app using this as an example

Things that might be fun to improve:

  • Grabbing the portlet data and writing our own front end
  • Adding user authentication
  • Add token authentication to Liferay so I don't have to hard code a user in my code.


That's it!  Hope my next post comes a lot quicker than this one.

Take care

Commenti Autore Data
Very nice, David, finally we have something... Iliyan Peychev 8 marzo 2012 2.51
Interesting! Jonas Yuan 8 marzo 2012 15.53
Looks interesting. I myself having worked with... Rushikesh S Thakkar 28 marzo 2012 5.11
That sounds interesting. I would like to find... David Truong 29 marzo 2012 12.37
@David, I agree with you on that. I too... Rushikesh S Thakkar 2 aprile 2012 1.15
Some changes I had to make in the code in order... Koen De Jaeger 4 giugno 2012 5.18
Test Michael C. Han 28 maggio 2014 10.14

Very nice, David, finally we have something working!

The first two potential use cases - to write a mobile site or a new frontend using this approach are really interesting - will be happy to participate!

Talking about improvements, what if we replace the HTTP connection with AMQP, for example?
Inviato il 08/03/12 2.51.
Inviato il 08/03/12 15.53.
Looks interesting. I myself having worked with Liferay, and currently working on Node.js keep thinking of use-cases where these two can be brought together.

The scenarios you suggested uses Liferay as content provider for Node.js. A scenario I thought of is other way around:
Socket.io + Node.js (on backend) with Liferay (on frontend): to display real-time streaming data (stock feeds, clock/time, monitoring dashboard, etc).
Inviato il 28/03/12 5.11.
That sounds interesting.

I would like to find a way to not have to run 2 different servers.
Inviato il 29/03/12 12.37 in risposta a Rushikesh S Thakkar.
I agree with you on that. I too wouldn't like to run 2 different servers. We can use comet libraries for Java - like Grizzly (http://grizzly.java.net/), but websocket support is not yet available in IE and webkit (AFAIK). That's where socket.io comes to rescue.
Moreover, Node.js is fares well on high load (plus: has good support for no-sql dbs like MongoDemoticon. So I wouldn't mind considering it as a backend for a Liferay app that renders realtime data.
Inviato il 02/04/12 1.15 in risposta a David Truong.
Some changes I had to make in the code in order to try the example.
Change "local.host" to "localhost".
Change "styles.css" to style.css".
Inviato il 04/06/12 5.18.
Inviato il 28/05/14 10.14.