Wednesday, 24 April 2013

How to obtain the user id of visited user profile ?

Using velocity Template in liferay

Template Code:

#set($groupLocalService =
$serviceLocator.findExceptionSafeService("com.liferay.portal.service.GroupLocalService"))
#set($group =
$groupLocalService.getGroup($getterUtil.getLong($groupId))) ##
$groupId is already available in the context

#if ($group.isUser())
#set($userLocalService =
$serviceLocator.findExceptionSafeService("com.liferay.portal.service.UserLocalService"))
#set($user = $userLocalService.getUserById($group.getClassPK()))
#set($name = $user.getFullName())
#else if ($group.isOrganization())
#set($orgLocalService =
$serviceLocator.findExceptionSafeService("com.liferay.portal.service.OrganizationLocalService"))
#set($org = $orgLocalService.getOrganization($group.getClassPK()))
#set($name = $org.getName())
#else
#set($name = $group.getName())
#end