voyent
Liferay logged user  XML
Forum Index -> Portals & Portlets
Author Message
Ragnarok

Joined: 27/Jan/2008 00:00:00
Messages: 12
Offline


How do i get the liferay logged user object or id in a managed bean of an icefaces portlet??
somebody told me that with request.getRemoteUser() i could get the userid, but how to get the Portlet Request Object in the managed bean??

Thanks a lot!
phil.gunbin


Joined: 30/Jan/2008 00:00:00
Messages: 29
Offline


You can get PortletRequest this way:
Code:
FacesContext.getExternalContext() .getRequest()
[Email]
h_aptioglu

Joined: 23/Jun/2007 00:00:00
Messages: 45
Offline


Code:
 FacesContext ctx = FacesContext.getCurrentInstance();
 		ExternalContext ectx = ctx.getExternalContext();
 		
 		user = ectx.getRemoteUser();
 		try {
 		user=UserLocalServiceUtil.getUserById(Long.parseLong(user)).getFirstName();
 		} catch (Exception e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		} 


ectx.getRemoteUser() return long value from liferay adn you can use it to find correct user from liferay

greating...
thorne

Joined: 10/Jun/2008 00:00:00
Messages: 12
Offline


I've got a bit of a problem here:

When I try and use the class UserServiceUtil I only get one method from Eclipse's autocomplete function. I've added the liferay-service.jar as an external JAR from the folder %LIFERAY_HOME/server/default/lib/ext.

Any help?

All good things lead to more good things
[Email]
thorne

Joined: 10/Jun/2008 00:00:00
Messages: 12
Offline


Nevermind, I figured out that when working in Eclipse, you need to add both liferay-service.jar and liferay-kernel.jar as external JARs.

All good things lead to more good things
[Email]
caioformiga

Joined: 12/Oct/2009 00:00:00
Messages: 9
Offline


The liferay-service.jar and liferay-kernel.jar has different names, at least in the liferay-portal-5.2.3. Instead of the referenced names, the names are portal-service.jar and portal-kernel.jar respectively

ps: I know that this post is a bit old..but just to keep it updated and somehow contribute with the community.
jrajakumar

Joined: 19/Dec/2011 21:11:08
Messages: 1
Offline


Get LoggedIn user from icefaces backing bean....

Code:
 String remoteUserId = (String)((Map)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("javax.portlet.userinfo")).get("liferay.user.id");
 			User user = UserServiceUtil.getUserById(Long.parseLong(remoteUserId));
 			String userName = user.getScreenName();			
 			System.out.println("LoggedIn user: "+userName );
 

 
Forum Index -> Portals & Portlets
Go to:   
Powered by JForum 2.1.7ice © JForum Team