1

I wanted to redirect user to default landing page based on the website access user has in liferay. I am using liferay DXP. I know how it can be done in liferay 6.2, but i don't have a idea how to override/extend DefaultLandingPageAction class in liferay 7.

Let me know if anybody has done this before.

Thanks!!

Dipti Ranparia
  • 570
  • 5
  • 17

1 Answers1

2

I assume that you are trying to redirect the user after login.

Have a look at this. Should do the trick. Place the class into a bundle and adjust the logic.

@Component(
      immediate = true,
        property = {
                "key=login.events.post"
        },
        service = LifecycleAction.class
)
public class LandingPageRouter implements LifecycleAction {
    private static Log LOG = LogFactoryUtil.getLog(LandingPageRouter.class);

    @Reference
    private UserLocalService userLocalService;

    @Override
    public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
       //Do some magic

       //build the path.
       LastPath lastPath = new LastPath(StringPool.BLANK, path);
       lifecycleEvent.getRequest().getSession().setAttribute(WebKeys.LAST_PATH, lastPath);
    }
}

LastPath works as in DefaultLandingPageAction.

Miroslav Ligas
  • 1,287
  • 8
  • 22
  • Hi Miroslav, Thanks for the help. yeah i was trying to redirect user to specific page after login. I was trying to extend the Action event instead of implementing LifecycleAction. This is worked for me. Thanks – Dipti Ranparia Sep 21 '17 at 06:07