
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.