Application Adapters

Definition #

Application Adapters are Hook Plugins that unlike our standard hooks which affect the entire portal, will allow us to scope the changes to a Site.

They were introduced in Liferay 6.1 and for the moment they only support jsp overwriting.

Examples #

A Sample Application Adapter can be found in the Liferay Plugins Repository.

How to create an application adapter #

To create a Application Adapter, all you need is a Hook with custom JSPs and "custom-jsp-global" set to false.

Like so:

<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
<custom-jsp-global>false</custom-jsp-global>

This will install an Application Adapter to your instance under the name of the hook. For Social Office, for example, you will see it says, "Social Office Hook".

Including the original JSP #

If you are overwriting a JSP from the portal, it is recommended to include the original one (when possible). In the global hooks, the mechanism to include the original jsp was including the same file ended with .portal.jsp However, when you are using application adapters the mechanism is different, in order to include the original file you should use the tag <liferay-util:include> with the attribute useCustomPage to false.

For example, if you are overwriting the view.jsp in the navigation portlet, but still want to include the original JSP from your you would to the following:

<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>

<liferay-util:include page="/html/portlet/navigation/view.jsp" useCustomPage="false"  />

How to install and use an application adapter #

Just deploy the hook with custom-jsp-global set to false and it will be authomatically available. 

Using Application Adapters is easy once they are installed. They will be available when creating a Site Templates or Site (under the page tab).

Conclusion #

This way other custom solutions that need custom JSPs without modifying the entire portal can do so with this method.

Developers can also package their solutions with Site Templates to make it seamless to the user.

For example, if I made an ERP solution and part of it creates sites for departments. Say it changes the bundled Wiki Portlet to extend its functionality but it only makes sense within the ERP context. I can, as the developer of the ERP solution, use Application Adapters to customize each department site for my ERP solution but still allow the front facing site to use the standard Liferay Wiki.

So programmatically, I create the ERP Site Template for users of my Application. Then from the users perspective, all they need to do is go to Control Panel > Sites click "Add" then "ERP Site" and a site designed for my webapp (including the Wiki extension) will automatically be created.

0 Attachments
37007 Views
Average (9 Votes)
The average rating is 3.6666666666666665 stars out of 5.
Comments
Threaded Replies Author Date
Great, just what we needed! Does anyone know... Mehrad Heidar December 23, 2011 3:01 AM
Nice feature! Ondřej Životský March 13, 2012 8:34 AM
I can't get this to work with dockbar JSPs.... Harri Paalanen March 29, 2012 10:07 PM
It seems I can use only ONE Application Adapter... Mykola M April 17, 2012 5:54 AM
I am not able to understand meaning of... Jignesh Vachhani May 28, 2012 4:55 AM
Very nice... It helped a lot... :-) Raja Seth January 1, 2013 11:11 PM
This is an excellent feature. It makes... Prasanta Bhuyan October 28, 2013 3:31 PM
Can I overwrite the files under portal folder... Srikanth Reddy Sanivarapu May 4, 2014 3:40 AM
Using 6.2 CE I have found you have to have your... Dave Weitzel November 5, 2014 8:45 AM

Great, just what we needed!

Does anyone know if this will be available in Enterprise 6.0?
Posted on 12/23/11 3:01 AM.
Nice feature!
Posted on 3/13/12 8:34 AM.
I can't get this to work with dockbar JSPs. With the global setting true it works fine but nothing happens if it is set to false and the hook is selected for site.
Posted on 3/29/12 10:07 PM.
It seems I can use only ONE Application Adapter per Site.
So if I have two hooks and want to convert them to Application Adapters - I won't be able to use both together for one site, unless I combine them together?
Posted on 4/17/12 5:54 AM.
I am not able to understand meaning of "Application Adapters are Hook Plugins that unlike our standard hooks which affect the entire portal, will allow us to scope the changes to a Site. "

Can anyone elaborate in more descriptive form?
Posted on 5/28/12 4:55 AM.
Very nice... It helped a lot... :-)
Posted on 1/1/13 11:11 PM in reply to Jignesh Vachhani.
This is an excellent feature. It makes customization for multiple tenants on same portal instance super easy without ending up with tons of if elses. But I am wondering if this is applicable to the customization of JSPs alone or, if this can be extended to other customizations within hook.
Posted on 10/28/13 3:31 PM.
Can I overwrite the files under portal folder (liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\webapps\ROOT\html\portal\update_pass­word.jsp). I think I would make sense to document all the cases in the wiki. Please let us know. Thanks.
Posted on 5/4/14 3:40 AM.
Using 6.2 CE I have found you have to have your own version of any file that includes any customized jsps.
so if you say changed an jspf file you need to reference that as <filename>.<hook name>.jspf in the page including it.

This is when using the <%@ include file="/html/portlet/etcetc/subfile.jspf" %> statement

This gets complicated with include init.jsp as if you follow the rules you should use init-ext.jsp as your customization but in fact that needs to be included as init..<hook name>.jsp which means you have to change the init.jsp file you were avoiding to include it...

LPS-51360 created.
Posted on 11/5/14 8:45 AM.