Get Current User in Liferay:- We can find the current logged in user in liferay using the below code Script. There are two methods to get the current User of liferay as following:
1. we can directly use the PortalUtil class in Liferay.
PortalUtil.getUser(request).getFullName())
2. But we cannot access directly PortalUtil class in any where so we can use below code to get the current user with the help of ThemeDisplay Class.
ThemeDisplay themeDisp = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
System.out.println("Current---------->"+themeDisp.getUser().getFullName());
0 Comment(s)