Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
el ami ami
How to get group users
November 19, 2007 10:03 AM
Answer

el ami ami

Rank: New Member

Posts: 4

Join Date: November 15, 2007

Recent Posts

I want to get the group users of the current community programmaticly

thanks
Jorge Ferrer
RE: How to get group users
November 20, 2007 1:55 AM
Answer

Jorge Ferrer

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2764

Join Date: August 31, 2006

Recent Posts

Hi El Ami,

There is not an explicit method for that, but can be achieved using the search method in UserLocalService. Here is an example:

1
2    LinkedHashMap userParams = new LinkedHashMap();
3    userParams.put("usersGroups", new Long(group.getGroupId()));
4    List communityMembers = UserLocalServiceUtil.search(
5        company.getCompanyId(), null, null, null, null, null, null, userParams, false,
6        0, 10000, new ContactLastNameComparator(true));
Piergiorgio Lucidi
RE: How to get group users
February 1, 2011 7:19 AM
Answer

Piergiorgio Lucidi

Rank: New Member

Posts: 4

Join Date: June 10, 2009

Recent Posts

el ami ami:
I want to get the group users of the current community programmaticly

thanks


You can try to get users from a group in this way:
1
2List<User> users = GroupUtil.getUsers(groupId);


Hope this helps.
Daniel Aschauer
RE: How to get group users
October 16, 2013 1:41 AM
Answer

Daniel Aschauer

Rank: Junior Member

Posts: 39

Join Date: October 22, 2012

Recent Posts

This is a very old thread.
But anyway, maybe anybody know?
I currently alway get an exception when I try to read out the group user with GroupUtil.getUsers():

1org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one he
2re


Is there a way to avoid this?
thx, Daniel
Pankaj Kathiriya
RE: How to get group users
October 16, 2013 1:54 AM
Answer

Pankaj Kathiriya

Rank: Liferay Master

Posts: 677

Join Date: August 4, 2010

Recent Posts

GroupUtil.java[persistence layer] cant be accessed outside your Implementation classes[your custom or OOB , XXXXLocalServiceImpl.java ] because it requires Hibernate session to be bound.

And to get group user UserLocalServiceUtil.getGroupUsers(long groupId) would help instead GroupUtil.getUsers.

HTH,
Pankaj K