In my last post, I discussed about action hook. In this post, you will learn about filter hook in Liferay7/DXP.
Just a quick recap in case you have not read my previous post. Liferay provides mechanism to override behaviour for out-of-the-box features is called hook. Liferay supports following types of hook,
After looking at above list of filters, you may have question that where filter hook is applicable in development?
Filter hook are used for intercepting HTTP request to execute piece of code before it reaches to execution logic. This is like HTTP Filter.
Following are the prerequisite to start with hook development in Liferay 7/DXP.
There is a difference in way to implement hook in Liferay 7/DXP compare to prior versions as DXP does not provides option for XML configurations. Now Let’s create Filter hook in liferay7/DXP using following steps,
Select File menu → click New → select Liferay Workspace Project. Upon creation of the workspace, the structure should look like below:
Open File menu → click New → select Liferay Module Project. Provide project name as ‘FilterHook’ and click on ‘Next’.
Now class FilterHook with package com.enprowess.filterclass is created in workspace module as follow,
Now, you have filter hook ready to deploy in Liferay.
We at EnProwess believes in sharing knowledge to help open source community to grow. In my next post, I will talk about JSP hook. Till then happy learning!
Share it :
©EnProwess, 2017 All Right Reserved.