Cookies on this site

We would like to use cookies to understand how the site is used and to measure our campaigns. Nothing is set until you choose, and you can change your mind at any time from “Cookie settings” at the foot of every page. Privacy policy

Contact UsContact Us

Resources / Blogs

Cloud & apps

Liferay Hooks for customizing Liferay portlets

Hooks are powerful tools to customize and extend features of liferay components. Learn how to begin using them with the login portlet.

· · 2 min read

Liferay portlets

>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.

← All articles

Case studies

Cloud Consulting in practice

Client names are withheld. We are happy to share details on a call.

All case studies
  • Delivered

    On-prem → Amazon RDS

    Nonprofit

    Cloud Consulting

    Oracle from on-premises to Amazon RDS for a national nonprofit

    The nonprofit's on-premises Oracle database had become hard to maintain and scale. We planned the move with automated workflows and validation tests, migrated to Amazon RDS for Oracle with minimal disruption and left a repeatable process for future changes.

    • Automated, tested migration
    • Less day-to-day database upkeep
  • Delivered

    600k files, < 3 days

    Document management

    Microsoft

    600,000 documents moved from ImageRight to SharePoint in under three days

    A one-file-at-a-time script would have needed about 22 days of continuous running. We rebuilt the migration around a SQL work queue with parallel uploads, automatic retries and crash recovery, and it finished unattended in under three days.

    • 1,125 → 8,314 files per hour
    • Under 3 days instead of about 22
  • Delivered

    Every change, flagged

    Food manufacturing

    AI Consulting

    Label comparison agent for a national food cooperative

    Compares two versions of a product label, highlights every change, annotates the PDF and returns an audit-ready list of differences. We moved it from Copilot Studio to Azure Functions when the document processing outgrew the low-code platform.

    • Audit-ready differences in one chat turn
    • Rebuilt from low-code to cloud functions

Keep reading

All Cloud & apps articles

Moving an application to the cloud?

Request a migration plan consult. We will scope the move with you and come back with a fixed-scope plan.