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.

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)
Tommy,
this message "java.net.MalformedURLException: unknown protocol: d" indicates that you've provided malformed URL which WURFL can not parse. I do not use Windows and I don't know what is the correct way to set the Windows path up, but it seems "/D:/Apps/liferay-portal-6.0.6/wurfl/wurfl-latest.zip" can not be interpreted correctly. I would try to remove the first "/" and see if that helps.
BTW, if "D:/Apps/liferay-portal-6.0.6" is the folder where your Liferay portal is installed you don't need to change portal.properties at all. The default setting "${liferay.home}/wurfl/wurfl-latest.zip" should work!
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
I guess the hook and web plugin would work without changes. Try do download the source code and build them with Liferay 6.0.2 SDK.
For the EXT plugin you'll have to check whether the classes it modifies have changed between 6.0.2 and 6.0.5 (do an SVN diff between appropriate tags). If there are no changes, then simply rebuild EXT plugin with Liferay 6.0.2 SDK. If there are changes you'll need to copy the files from Liferay 6.0.2 source code and apply changes manually before building EXT plugin.
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 ?
Marcin,
I was thinking about it. It's relatively easy to do (In fact I it was implemented in one of the commercial projects using the extension). However I never got the time to implement it in the extension itself.
Francois,
I'm not a big fan of ext plugins myself. However there is no other option in this case as some core Liferay logic needed to be changed.
As for upgrades it should work with 6.0.6 OOTB (if not let me know and I'll release a dedicated version). For 6.0 EE you'll have to recompile it with appropriate SDK. From 6.1 there should not be a problem as I contributed the code to Liferay and it will be available as part of Liferay 6.1
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,
Asaf, make sure you have installed WURFL's database (wurfl-latest.zip) and "wurfl.main" contains correct path.
I'm using a Firefox plug-in called "User Agent Switcher" (http://chrispederick.com/work/user-agent-switcher/). The deices are configured according UA data found in WURLF's database.
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 !!!