Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Liferay: How to create Custom Action By Hook?

    • 0
    • 2
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 606
    Comment on it

    We can modify Liferay JSP, services, properties by using Hooks. One of the main use of Hook is we can implement our Custom Action.

    So what is Custom Action?

    When you see in your liferay source code. You will see there multiple entries which contain events. For example, etc. These events are called actions and every action has its own specific task. The events (or action) defines the task before user log in and defines task after user login.

    I'm taking here example of creating Custom Action for "" event.

    Follow the below steps to create Custom Action:

    1. Create Liferay Plugin Project of type Hook.

    2. Create a new class CustomLoginAction.
    3. This class is the Custom Action.
    package com.evon.action;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class CustomLoginAction extends Action{
        public void run(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
                throws ActionException {
             * Write your custom code here, this code will run after user logged in
            System.out.println("In Action after login..............");
    1. Now tell Liferay that CustomLoginAction is the post login action by adding below line in your
    #Tue June 16 17:04:57 IST 2015
    1. Now define the below line in "liferay-hook.xml" to tell Liferay where the exist.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "">
    1. Deploy the Hook and try to login. After logged in you will see the message that you mentioned in our custom action.
    // System.out.println("In Action after login..............");

    Hope this will help you :)

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: