There are more than one way to do this. Let's look at some of the options available.
- User user = (User) request.getAttribute(WebKeys.USER);
The User class is the Liferay's model User class. - ThemeDisplay td = (ThemeDisplay) request.getAttribute( WebKeys.THEME_DISPLAY );
User user = td.getUser();
This ' ThemeDisplay 'class can be used to get various information about the portal page,user and theme. Classes ThemeDisplay, User and WebKeys are available in portal-service.jar - User currentUser = PortalUtil.getUser( request );
The 'PortalUtil' has various utility functions , which come handy during Liferay Programming. This is also a part of the Portal-service.jar. - LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
User currentUser=liferayFacesContext.getUser();
The class 'PortalFacesContext' has been renamed to 'LiferayFacesContext'.This class exists in order to assist with migrating old JSF 1.2 based projects from the legacy PortletFaces-Tools project to the new LiferayFaces project.
Hope It helps you in your portal programming. Happy Coding :)
No comments:
Post a Comment