Creating Liferay JSP hook with Liferay 7
Liferay 7 doesnt support the hook, as all of the bundles are generated using the OSGI. In OSGI you need to create a fragment and attach the same with the Orginal module. By this we can chnage the existing JSPs in the module.
Liferay IDE as of now doesnt supooort the direct creation of the hook. So we need to create the hook project using blade and then we can go ahead and do rest of the stuff using the IDE.
Also point to keep in mind is that Liferay 7 GA2 is having a bug due to which theJSP hooks are not getting deployed in the liferay. For further information on that you can go ahead and have a look on this issue https://issues.liferay.com/browse/LPS-66814.
So in this tutorial we will be using the Liferay 7 GA 1.
Following is the command to create a blank project for JSP hook
blade create -t fragment -h <HOST_BUNDLE_SYMBOLIC_NAME> -H <HOST_BUNDLE_VERSION> <PROJECT_NAME>
HOW TO CREATE JSP HOOK IN LIFERAY 7 USING FRAGMENTS TEMPLATE
Step 1 -> Find the value for -h i.e the Host bundle Symbolic name. Open the GOGO shell as in the below figure
And type lb
This will list down all of the modules/bundles running in that particular server. As we are working on the login jsp hook. we can find the login modules by writing the following command
lb | grep Login
Here the list of all of the Login modules. Now we are interested in the Login Web module. Modules are listed in the following fashion
BUNDLE_ID | STATUS |LEVEL |NAME (VERSION)
We can see that Lifeary Login Bundle with Bundle ID 371 is active and is of version (1.0.3).
So now we need to find out the HOST_BUNDLE_SYMBOLIC_NAME and the HOST_BUNDLE_VERSION in order to create a fragment.
We can get the further details of the bundle by using the command b <BUNDLE_ID>
so we will punch in b 371 this will give us the complete details of the bundle.
We can see that first line is com.liferay.login.web_1.0.3[371], this will give the desired result that we are seeking.
com.liferay.login.web -> HOST_BUNDLE_SYMBOLIC_NAME
1.0.3 -> HOST_BUNDLE_VERSION
So now we are having all of the required details so that we can create a JSP hook for login portlet.
F:\LR7\wokspace\FirstWorkspace\modules>blade create -t fragment -h com.liferay.login.web -H 1.0.3 my-login-jsp-hook
This will create a blank project in the module folder.
Now we need to copy down the JSPs from the login module which we want to change. To do that import the source of liferay into eclipse and go to the
/portal-master/modules/apps/foundation/login/login-web/src/main/resources/META-INF/resources
Now copy down the required jsps and paste them into the project that we had just created.
So the result will be something like this
Now customize the changes in the login.jsp and post that deploy the project
Once deployed you can see that the changes are reflected in the portal as shown below
RELATED POSTS