我想根据用户在liferay中访问的网站将用户重定向到默认目标网页。我正在使用liferay DXP。我知道如何在liferay 6.2中完成它,但我不知道如何在liferay 7中覆盖/扩展DefaultLandingPageAction类。
如果有人事先这样做,请告诉我。
谢谢!
答案 0 :(得分:2)
我假设您在登录后尝试重定向用户。
看看这个。应该做的伎俩。 将类放入一个包中并调整逻辑。
@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的工作方式与DefaultLandingPageAction相同。