Liferay multi-device extension

| 16 Comments | No TrackBacks |

  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.zip however 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.

No TrackBacks

TrackBack URL: http://milen.commsen.com/cgi-bin/mt5/mt-tb.cgi/18

16 Comments

great work Man. Thanks.. I will surely check this out soon.

I tried and tried to do what is mentioned on this blog.

Steps:
1. Copy all 3 jars in the deploy directory.
2. Start Liferay and let the jars deploy.
3. modified the portal.properties in the wurfl-web web app to reflect wurfl.main=/D:/Apps/liferay-portal-6.0.6/wurfl/wurfl-latest.zip

The multi-device-ext plugin works fine. I can see the modifications on the web site.

The device-rules-hook works fine. I don't see and exceptions.

The problem occurs with the wurfl-web extention.

I keep getting the following error, please help...

Thanks in advance..
--------------------------------------------------

Exception in thread "commsen/device_recognition_provider" net.sourceforge.wurfl.core.resource.WURFLResourceException: WURFL unexpected exception
at net.sourceforge.wurfl.core.resource.XMLResource.openInputStream(XMLResource.java:265)
at net.sourceforge.wurfl.core.resource.XMLResource.getData(XMLResource.java:127)
at net.sourceforge.wurfl.core.resource.DefaultWURFLModel.(DefaultWURFLModel.java:80)
at net.sourceforge.wurfl.core.CustomWURFLHolder.init(CustomWURFLHolder.java:116)
at net.sourceforge.wurfl.core.CustomWURFLHolder.(CustomWURFLHolder.java:72)
at com.commsen.liferay.wurfl.LiferayWURFLHolder.init(LiferayWURFLHolder.java:51)
at com.commsen.liferay.wurfl.LiferayWURFLHolder.getWURFLManager(LiferayWURFLHolder.java:63)
at com.commsen.liferay.wurfl.WurflDeviceRecognitionProvider.getDeviceFromRequest(WurflDeviceRecognitionProvider.java:45)
at com.commsen.liferay.multidevice.DeviceRecognitionMessageListener.receive(DeviceRecognitionMessageListener.java:49)
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:63)
at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:61)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.MalformedURLException: unknown protocol: d
at java.net.URL.(URL.java:574)
at java.net.URL.(URL.java:464)
at java.net.URL.(URL.java:413)
at java.net.URI.toURL(URI.java:1081)
at net.sourceforge.wurfl.core.resource.XMLResource.openInputStream(XMLResource.java:254)

hi Milen - I was able to install and run your extention. It is very useful and does as described. However I did have to fix one bug to get it to run on windows.

It seems that the error Tommy was seeing is an (old) problem with Java1.6 that is still occuring :
http://bugs.sun.com/view_bug.do?bug_id=6506304

My temp "fix" was to change class LiferayWURFLHolder and create the File ojbect manually - and then pass that. I do not think it is a proper fix but for proof-of-concept it was OK for me


File theFile = new File(mainFile);

// wurflHolder = new CustomWURFLHolder(mainFile, patchFiles);
wurflHolder = new CustomWURFLHolder(theFile);


Anyway - great work.
regards
dave

Excellent Milen.. Great Stuff.. understand that it supports 6.0.5 onwards.. We are using: is it possible to support liferay 6.0.2 ..Any advice

Thanks for sharing your effort Milen.

Special thanks for dave for the windows hint.

Milen,

I finally got it to work. One question for ya though, is there any way to override the redirect to go back to the full site? Once my iPhone got redirected to my iPhone version of the site, maybe there is some hidden way to do allow it to go back to the full site version. If not yet, do you plan to implement anything like this?

Hum, ext plugin make me afraid about intrusive !
How can we garantee Liferay updates after ?

I tried deploying all 3 plugins.
The "device rules" was added but when choosing it there's only one option which is "Brand is" with only "Any" option.

can you please assist?

tx

Hi Milen,

In your clip, I see there are some mobile simulator bookmark links. How did you have them?

Thanks,

Hi Milen,
Great work...I'm able to deploy and run these war files...
Initially getting some problem of malformed url, but Dave's solution worked for me...

Cheers !!!

Leave a comment

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.01