Hi folks, dynamic web-development has become a very competitive field in the past few years, be it UI, middleware or back-end frameworks and we have a myriad of technologies at our disposal while starting a project. In this post I’m gonna talk about Liferay, a very handy portlet container that provides for easy development and customization. Mind you, this won’t be much of a tutorial, rather, my experience in working on Liferay for project development.

I won’t delve into the details of creating a portlet or the back-end design as they tend to vary according to project requirements, suffice to say, Liferay comes with a nice in-built MVC framework that makes the job easier for you. But a word of advice: try to keep the separate components, viz., the GUI, the Java classes, the hooks in separate WAR files; it makes for good scalability in large scale projects. Now, coming back to the topic of Liferay hooks, it was introduced in Liferay 5.1 and improved up to Liferay 6.2 and they provide great customization features to influence the portal’s behavior by deployable items. More detailed documentation can be found at http://www.liferay.com/de/community/wiki/-/wiki/Main/Portal+Hook+Plugins , however I found them a bit outdated and somewhat cryptic at times, so I write this post with a case in point: customizing the login portlet.

We begin by creating a new “Liferay Plugin Project” of “Plugin type: hook” in the Liferay IDE:

Next, by right-clicking on the hook that we just created in the Navigator pane, select “New” and then “Liferay Hook Configuration”.

In the window that pops-up, check “custom JSPs” since we are only looking to customize the design of the default login portlet:

NOTE: If you want custom login actions, you’ll have to check “Portal properties” and “Services” and then map the custom actions in the properties. More on that here: https://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/perform-a-custom-action-with-hook-liferay-portal-6-2-dev-guide-en

After that we’ll have to select “Add from Liferay” and select “login.jsp” from ‘html/portlet/login/’ and make necessary modifications

On creating the hook, the original jsp file from the login page is not used, instead, the hook creates a new file called ‘login.portal.jsp‘ which is actually used when the hook is deployed. You can verify this at “/../tomcat-7.0.42/webapps/ROOT/html/portlet/login/” where you’ll find both ‘login.jsp’ and ‘login.portal.jsp’. This is true for any other custom JSPs, and when the hook is undeployed, the ‘*.portal.jsp’ is deleted and the original jsp is used.