Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Lambert Mickael
Live Users in a personnal portlet
February 18, 2013 2:29 AM
Answer

Lambert Mickael

Rank: Junior Member

Posts: 58

Join Date: December 29, 2011

Recent Posts

Hello everyone,

I have a problem, i want to display a list of connected Users in a portlet that i have developped, but i don't know how.

I know that i have to enable two properties in my portal-ext.properties : live.users.enabled and another.

I already did this. My situation is that i want to display this list not in monitoring in the control panel but in the body of my portlet.

Can someone please help me ?
Kowbathullah Gnaniyar
RE: Live Users in a personnal portlet
February 18, 2013 2:54 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 608

Join Date: December 19, 2007

Recent Posts

After setting this property :
live.users.enabled=true


You can access like this

LiveUsers. getSessionUsers(companyId)
Lambert Mickael
RE: Live Users in a personnal portlet
February 18, 2013 2:56 AM
Answer

Lambert Mickael

Rank: Junior Member

Posts: 58

Join Date: December 29, 2011

Recent Posts

Gnaniyar Zubair:
After setting this property :
live.users.enabled=true


You can access like this

LiveUsers. getSessionUsers(companyId)


Unfortunately, i think this class is only in portal-impl.jar and not in portal-service.jar, so i can't access ...
Kowbathullah Gnaniyar
RE: Live Users in a personnal portlet
February 18, 2013 2:59 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 608

Join Date: December 19, 2007

Recent Posts

Yes you are right. Just i verified now. In chat portlet they are getting live users through
StatusLocalServiceUtil
.

Please check the code from chat portlet. You might get some clarity.
Lambert Mickael
RE: Live Users in a personnal portlet
February 18, 2013 3:00 AM
Answer

Lambert Mickael

Rank: Junior Member

Posts: 58

Join Date: December 29, 2011

Recent Posts

Gnaniyar Zubair:
Yes you are right. Just i verified now. In chat portlet they are getting live users through
StatusLocalServiceUtil
.

Please check the code from chat portlet. You might get some clarity.



I try this, i'll tell you if it works or not. Thanks for your quick answers
Lambert Mickael
RE: Live Users in a personnal portlet
February 18, 2013 4:52 AM
Answer

Lambert Mickael

Rank: Junior Member

Posts: 58

Join Date: December 29, 2011

Recent Posts

Lambert Mickael:
Gnaniyar Zubair:
Yes you are right. Just i verified now. In chat portlet they are getting live users through
StatusLocalServiceUtil
.

Please check the code from chat portlet. You might get some clarity.



I try this, i'll tell you if it works or not. Thanks for your quick answers


I did this :

 1
 2List<Object[]> buddies = null;
 3    
 4     long buddiesModifiedDate = System.currentTimeMillis() - Time.MINUTE;
 5    
 6     ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
 7    
 8     buddies = StatusLocalServiceUtil.getAllStatuses(themeDisplay.getCompanyId(), themeDisplay.getUserId(), buddiesModifiedDate, 0, SearchContainer.DEFAULT_DELTA);
 9    
10     out.println("Online visiting Users ="+ buddies.size());


I import these 3 classes : <%@ page import="com.liferay.chat.service.StatusLocalServiceUtil" %>
<%@ page import="com.liferay.portal.kernel.util.Time" %>
<%@ page import="com.liferay.portal.kernel.dao.search.SearchContainer" %>

There are 5 parameters for the fonction getAllStatuses with the new Liferay (6.1.1)

And it tells me this :

"org.apache.jasper.JasperException : An exception occured processing JSP page 'mypage' at line 24"

The line 24 is this line :

1buddies = StatusLocalServiceUtil.getAllStatuses(themeDisplay.getCompanyId(), themeDisplay.getUserId(), buddiesModifiedDate, 0, SearchContainer.DEFAULT_DELTA);
Kowbathullah Gnaniyar
RE: Live Users in a personnal portlet
February 18, 2013 5:11 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 608

Join Date: December 19, 2007

Recent Posts

How did you get the StatusLcoalServiceUtil which is there in Chat plugin..?
Lambert Mickael
RE: Live Users in a personnal portlet
February 18, 2013 6:21 AM
Answer

Lambert Mickael

Rank: Junior Member

Posts: 58

Join Date: December 29, 2011

Recent Posts

I searched in the forum and found this way to do that.

But it's really weird that there is no way to get all the users online!
Lambert Mickael
RE: Live Users in a personnal portlet
February 18, 2013 8:37 AM
Answer

Lambert Mickael

Rank: Junior Member

Posts: 58

Join Date: December 29, 2011

Recent Posts

Gnaniyar Zubair:
How did you get the StatusLcoalServiceUtil which is there in Chat plugin..?


So, can you help me ? :s

I'm sorry, but i'm really looking for a solution... I don't understand why there is this stacktrace ...
Kowbathullah Gnaniyar
RE: Live Users in a personnal portlet
February 18, 2013 11:04 PM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 608

Join Date: December 19, 2007

Recent Posts

Sure will look into that. Have a look here . they have counted the users manually by extending LoginPostAction thorugh HOOK.

http://www.liferay.com/community/forums/-/message_boards/message/1885734

But I am not sure that this is a best approach.