Why create hook?
If you need to override the core JSPs from a module deployed to the OSGi runtime, you need a fragment module(Hook) which provides complete copy of the original JSP. In which you can make any modifications as per your requirements.
About this blog
In this blog, I have described steps to override a Liferay DXP/7’s JSPs. Please find jar file of fragment module at the end of blog for reference.
Before starting this blog, basic knowledge about Liferay IDE and Liferay Portal is required.
Sample Problem: Overriding login.jsp of com.liferay.login.web module using fragment module.
Override Liferay JSP: (Using blade CLI)
- Here, I am going to override login page of liferay DXP/7. So, we need to create a fragment module for login page.
To create a fragment run following command in terminal under your liferay workspace.
blade create -t fragment -h <HOST_BUNDLE_SYMBOLIC_NAME> -H <HOST_SYMBOLIC_VERSION> <PROJECT_NAME>
- Using Gogo Shell you can find “HOST_BUNDLE_SYMBOLIC_NAME” and “HOST_BUNDLE_VERSION”.
- Run following command in your terminal.
blade create -t fragment -h com.liferay.login.web -H 1.0.7 my-login-jsp-hook
- Make “login.jsp” in ”/my-login-jsp-hook/src/main/resources/META-INF/resources” folder.
Copy source code of login.jsp from liferay portal and paste in your custom “login.jsp”. You can add your changes into this file.
- Now build and deploy “my.login.jsp.hook.jar” on your Liferay DXP / 7 server.
For professional paid support, you may contact us at firstname.lastname@example.org .