Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Overriding Login Struts action in liferay

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 897
    Comment on it

    We can override Login Struts action by using Hook.

    In the below example we are overriding struts action "/login/login". When a user login in Liferay "com.liferay.portlet.login.action.LoginAction" is the action class that calls.

    Follow the below steps to perform the change of Struts Action:

    1. Create Liferay Plugin Project of type Hook.
    1. Write the below code in liferay-hook.xml to override Login Struts action
    <?xml version="1.0"?>
    <!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" ";6_2&#95;0.dtd">
    1. package com.evon.action;
    import javax.portlet.ActionRequest;
    import javax.portlet.ActionResponse;
    import javax.portlet.PortletConfig;
    import javax.portlet.RenderRequest;
    import javax.portlet.RenderResponse;
    import com.liferay.portal.kernel.struts.BaseStrutsPortletAction;
    import com.liferay.portal.kernel.struts.StrutsPortletAction;
    public class CustomLoginAction extends BaseStrutsPortletAction{
        public void processAction(StrutsPortletAction originalStrutsPortletAction,
                PortletConfig portletConfig, ActionRequest actionRequest,
                ActionResponse actionResponse) throws Exception {
             * This is the custom process action
             * Once you try to login this method will be invoked
             * We can write our own logic here
             * Invoke the original struts action at the end
            System.out.println("in Custom login........................");
                    originalStrutsPortletAction, portletConfig, actionRequest,
        public String render(
                StrutsPortletAction originalStrutsPortletAction,
                PortletConfig portletConfig, RenderRequest renderRequest,
                RenderResponse renderResponse)
            throws Exception {
            return originalStrutsPortletAction.render(
                null, portletConfig, renderRequest, renderResponse);
    1. Deploy the Hook and try to login, this will invoke method of CustomLoginAction class instead of default one.

 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: