Hooks are commonly used to override web resources, found in
portal-web in the
files, or images.
Important: A JSPF change takes effect only when you modify a JSP that includes the JSPF.
Use the hook project we created earlier or create a new hook project.
liferay-hook.xmlfile from your project’s
docroot/WEB-INFfolder in Liferay IDE. By default, it opens in Overview mode. This mode, gives you a graphical user interface for developing your hook. You can toggle between overview mode and source mode via their respective tabs for the
Select the Custom JSPs folder from the outline to bring up the custom JSP options. Select the checkbox Customize Liferay Portal JSPs and create the default custom JSP folder
/META-INF/custom_jsps, by clicking the icon that has the three yellow diamonds.
Add to the listing of custom JSPs by clicking the plus icon and specifying Portal’s
html/portal/terms_of_use.jspfile. Hint, the browse icon on the right-hand side within the custom JSP text field simplifies finding the JSP you want to customize. It lets you scroll through the JSPs that are accessible and lets you specify key words to narrow your search.
Open your hook’s
docroot/META-INF/custom_jsps/html/portal/terms_of_use.jspfile and modify it as necessary.
Deploy your hook and wait until it is deployed successfully.
The original JSP stays in the cache until the cache is cleared or Liferay Portal is restarted. To clear the cache, navigate to Control Panel → Server Administration and click on the appropriate Clear content … buttons in the Resources tab.
directory. One is called
terms_of_use.jsp and another
terms_of_use.jsp is your hook’s version, while
terms_of_use.portal.jsp is the original. To revert back to the original,
undeploy your hook. Your replacement JSP is removed, and the
is automatically renamed, taking its place. You can override any JSP in the
Liferay core, while retaining thew ability to easily revert your changes.
However, it’s not possible to override the same JSP from multiple hooks; Liferay
won’t know which version to use.
Next, we’ll look at a different way to customize a JSP.