Search This Blog

Tuesday, May 25, 2010

Implementing JSP Hooks in Liferay

Implementing Hook is an easy way to modify existing portal source, here we can see how to modify a jsp which resides in portal.

Steps:
I assume that SDk Plugin has been installed and configured properly.

sdk-plugins will be referred as PLUGINS_HOME.

1. Go to hooks folder which is available under PLUGINS_HOME. as show in the image.
2.create a folder under hooks, for example lets create JSPHook.
3. create docroot under JSPHook.
4. create build.xml under JSPHook.
5. place the below content in your build.xml for deploying/building your hook.

<?xml version="1.0"?>
<project name="hooks" basedir="." default="deploy">
<import file="../build-common-hook.xml">
</project>


6. create WEB-INF under docroot.
7. create liferay-hook.xml. place the below content in liferay-hook.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 5.1.0//EN" "http://www.liferay.com/dtd/liferay-hook_5_1_0.dtd">

<hook>
<custom-jsp-dir>/WEB-INF/CustomJSPs</custom-jsp-dir>
</hook>


8. create the jsp folder structure of the portlet which you are going to implement the hook.
for example: if you are customizing view of blogs portlet, then the you have to create the folder structure as /WEB-INF/CustomJSPs/html/portlet/blogs/view.jsp.
FULL PAtH from PLUGIN_HOME looks like this PLUGIN_HOME/JSPHook/docroot/WEB-INF/CustomJSPs/html/portlet/blogs/view.jsp
now open the view.jsp and customize it accordingly.

9. Go to plugins/hook and do ant deploy
10. check for the changes which you have made in view.jsp.

No comments:

Post a Comment