11/28/2013

A Primefaces Portlet for Liferay 6.2

What´s liferay without the beauty of JSF ? Here is a little tutorial to get started with liferay 6.2 and primefaces 3.5 .

Please configure  your eclipse and liferay installation like you usually do. Start up your server, acknowledge your basic configuration and add the plugins-sdk to eclipse. Please note that the plugins-sdk you´re currently able to download does not specifically allow you to create a liferay 6.2 server. You can just select the 6.1 one, because they both use basically the same tomcat version. I suppose that liferay is going to update that.

Use the plugins-sdk portlet creating mechanism and select "JSF 2.0" and primefaces:





After you´ve done that, your portlet is created. Please run the standard build.xml "deploy" target. Liferay 6.2 will use apache ivy to download additional libs that it will put inside your portlets WEB-INF/lib container. 

But ... as you will see : it fails :


Buildfile: /Users/danielbreitner/Documents/workspaces/Ted/plugins-sdk/portlets/Test-portlet/build.xml
[ivy:resolve] :: Apache Ivy 2.3.0 - 20130110142753 :: http://ant.apache.org/ivy/ ::
[ivy:resolve] :: loading settings :: file = .../plugins-sdk/ivy-settings.xml
[ivy:resolve] :: problems summary ::
[ivy:resolve] :::: WARNINGS
[ivy:resolve] module not found: com.liferay.faces#liferay-faces-bridge-api;3.2.4-ga5
[ivy:resolve] ==== jboss-nexus: tried
[ivy:resolve]   https://repository.jboss.org/nexus/content/repositories/releases/com/liferay/faces/liferay-faces-bridge-api/3.2.4-ga5/liferay-faces-bridge-api-3.2.4-ga5.pom
[ivy:resolve]   -- artifact com.liferay.faces#liferay-faces-bridge-api;3.2.4-ga5!liferay-faces-bridge-api.jar:
[ivy:resolve]   https://repository.jboss.org/nexus/content/repositories/releases/com/liferay/faces/liferay-faces-bridge-api/3.2.4-ga5/liferay-faces-bridge-api-3.2.4-ga5.jar

[...]



It fails, because all the repositories don´t seem to have the newest version of the liferay faces bridge. We can avoid that, if we just change the version the build process is looking for.
Note: I am sure this version will be added in the next time, so be sure to check it from time to time and then revert the changes that I am proposing here:

Open the file "ivy.xml" that is in your portlet´s root folder, and change this:


<dependency name="liferay-faces-bridge-api" org="com.liferay.faces" rev="3.2.4-ga5" />
<dependency name="liferay-faces-bridge-impl" org="com.liferay.faces" rev="3.2.4-ga5" />
<dependency name="liferay-faces-portal" org="com.liferay.faces" rev="3.2.4-ga5" />

<dependency name="liferay-faces-util" org="com.liferay.faces" rev="3.2.4-ga5" />

into that:

<dependency name="liferay-faces-bridge-api" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-bridge-impl" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-portal" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-util" org="com.liferay.faces" rev="3.1.3-ga4" />


That´s it. Run "deploy" again and you should now get a working primefaces portlet.

For your convenience, I´ve also uploaded a working war-file that you can try out: Primefaces Liferay 6.2 portlet

If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.