« Back

node.js with Liferay 6.1

Company Blogs March 7, 2012 By 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

Threaded Replies Author Date
Very nice, David, finally we have something... Iliyan Peychev March 8, 2012 2:51 AM
Interesting! Jonas Yuan March 8, 2012 3:53 PM
Looks interesting. I myself having worked with... Rushikesh S Thakkar March 28, 2012 5:11 AM
That sounds interesting. I would like to find... David Truong March 29, 2012 12:37 PM
@David, I agree with you on that. I too... Rushikesh S Thakkar April 2, 2012 1:15 AM
Some changes I had to make in the code in order... Koen De Jaeger June 4, 2012 5:18 AM
Test Michael C. Han May 28, 2014 10:14 AM

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?
Posted on 3/8/12 2:51 AM.
Posted on 3/8/12 3:53 PM.
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).
Posted on 3/28/12 5:11 AM.
That sounds interesting.

I would like to find a way to not have to run 2 different servers.
Posted on 3/29/12 12:37 PM in reply to 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.
Posted on 4/2/12 1:15 AM in reply to 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".
Posted on 6/4/12 5:18 AM.
Posted on 5/28/14 10:14 AM.