Sunday, June 2, 2013

Richfaces oncomplete not working in Liferay

The oncomplete attribute is a very common and useful in RichFaces application to invoke a javascript function after calling a server side action.

<a4j:commandButton value="Some Action" action="#{testBean.someAction}" oncomplete="oncompleteScript" />

But this attribute is ignored in RichFaces portlet in Liferay.

The root cause is the Liferay portlet bridge.
When we create RichFaces 4 portlet in Liferay with Liferay IDE, it comes with the default Liferay jar (bridge-api, bridge-impl, portal, util)

The version of Liferay portlet bridge bundled with the Liferay IDE causing the oncomplete attribute being ignored.
Platform
1. Liferay 6.1.1
2. Richfaces 4.2.0 Final
3. Liferay Portlet Bridge 3.1.0

Solution:
What we need to do now is to download the latest version Liferay Portlet Bridge, and replace them in our RichFaces portlet project. eg, Liferay Portlet Bridge 3.1.1
update the Liferay portlet bridge to version 3.1.1

Now clean the project, and test with the following code in the RichFaces portlet.
It should works now.

<a4j:commandButton value="oncomplete test" onclick="alert(1);" oncomplete="alert(2);" />


Done!!

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...