Liferay multi-device extension
UPDATE: The extension described here targets Liferay 6.0. It was contributed to Liferay and is available out of the box since Liferay 6.1
Almost every portal related RFI/RFP my company has received in the last couple of years contained some requirements about mobile version. Fortunately the times when every device had it's own idea of how web content should be served are gone. Nowdays we can afford to pretty much ignore WML, C-HTML, ... as almost any modern device understands at least XHTML Mobile Profile. However this does not always mean there can be one mobile version for all. Here are some typical requirements:
- make a dedicated version for iPhone (imitate iPhone interface to make it look like native application)
- allow to switch between mobile and desktop version if device is smartphone
- provide alternative input methods if device does not have QWERTY keyboard
- design dedicated version for tablets
I have spent some time thinking about how to address this issues with Liferay Portal. Having some experience with WURFL, Volantice and designing web applications for mobile devices in general, I thought it would be great if I could dynamically change Liferay's look and feel based on device capabilities. And this is how Liferay multi-device extension was born.
Actually now there are 3 Liferay plug-ins which work together to deliver this functionality:
- multi-device-ext plugin (https://github.com/azzazzel/liferay-multi-device-ext) is the core plug-in. It provides the look and feel change logic, generic data model and "extension points" for other plug-ins which deliver things like device recognition and rule definition. It does so by employing Liferay's internal bus and can dynamically switch to new implementation when compatible plug-in is deployed. If you know how to replace Lucene with Solr, you know what I'm talking about.
- wurfl-web (https://github.com/azzazzel/liferay-wurfl-web) plug-in delivers device recognition based on WURFL. It contains WURFL API but does not contain WURFLD DB and patches. By default it expects to find the database in
${liferay.home}/wurfl/wurfl-latest.ziphowever you may change this in portal-ext.properties:
# Wurfl's main devices file
wurfl.main=${liferay.home}/wurfl/wurfl-latest.zip
# Wurfl's patch files
wurfl.patches=
- device-rules-hook (https://github.com/azzazzel/liferay-device-rules-hook) extends Liferay's look and feel management interface by adding additional tab "Device Rules". At the moment rules can be based on device's brand, model, operating system, browser and pointing method as well as whether the device is tablet, has QWERTY keyboard
Here is how it works:
The plug-ins are not yet in Liferay community plug-ins repository. I could'n figure out how to upload the EXT plugin and the other two make no sense without it. You can download plug-ins from here: http://sourceforge.net/projects/liferaymultidev/files/ or get the source code from https://github.com/azzazzel and build them yoursef. If you do so, please let me know what you think.
Liferay GWT portlet - how to make it "instanceable" and use GWT RPC
Every once in a while somebody asks about writing Liferay portlets in GWT. It seems a lot of people are successfully using GWT with Liferay but surprisingly I couldn't find any complete tutorial on the subject. There are a of course tutorials explaining the basics but what they concentrate on, is how to build single-instance and client-side-only portlets. This is good enough to get you started but chances are sooner or later you'll need to place two instances of the same GWT portlet on the same page and/or implement GWT RPC to make use of the Liferay services.
Liferay GWT portlet - replacing GWT-RPC with JSON
This is a continuation of my previous post Liferay GWT portlet - how to make it "instanceable" and use GWT RPC. The approach described there uses Liferay specific functionality called PortalDelegateServlet. This way one can easily use GWT RPC which somewhat simplifies client-server communication. However if you need to develop a JSR 286 portlet you need a more standard compatible way of doing AJAX calls. For this reason JSR 286 defines serverResource method and this post will show how to refactor the code to replace GWT RPC calls with exchanging JSON messages using serverResource method.