Fórum
Getting Online Users using StatusLocalServiceUtil of chatportlet
Becas Kostas, modificado 11 Anos atrás.
Getting Online Users using StatusLocalServiceUtil of chatportlet
Junior Member Postagens: 28 Data de Entrada: 30/08/12 Postagens Recentes
Hey,
I am facing a problem. I have created a custom porytlet where i display users with specific roles. I also want to display the status of that user that time (if it is online or not).
My view.jsp is :
The problem is that all users seems to be online, where they are not! Why is that happening? Am i doing something wrong?
I am facing a problem. I have created a custom porytlet where i display users with specific roles. I also want to display the status of that user that time (if it is online or not).
My view.jsp is :
<%
/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@page import="com.liferay.portal.service.RoleLocalServiceUtil" %>
<%@page import="com.liferay.portal.theme.ThemeDisplay" %>
<%@page import="com.liferay.portal.service.RoleLocalServiceUtil" %>
<%@page import="com.liferay.portal.model.Role" %>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.model.User" %>
<%@page import="com.liferay.chat.service.StatusLocalServiceUtil" %>
<%@page import="java.util.List" %>
<%@page import="com.liferay.portal.service.UserLocalServiceUtil" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<portlet:defineobjects />
<%ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
final Role user = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),"ProducersRole");
List<user> users = UserLocalServiceUtil.getRoleUsers(user.getRoleId());
%>
<div class="producersresults">
<liferay-ui:search-container delta="10" emptyresultsmessage="no-producers-were-found">
<liferay-ui:search-container-results results="<%=users%>" total="<%=UserLocalServiceUtil.getRoleUsersCount(user.getRoleId())%>" />
<liferay-ui:search-container-row classname="com.liferay.portal.model.User" keyproperty="userId" modelvar="user1">
<liferay-ui:search-container-column-text name="name" value="<%=user1.getFullName() %>" />
<liferay-ui:search-container-column-text name="online" [b] value="<%=String.valueOf(StatusLocalServiceUtil.getUserStatus(user1.getUserId()).getOnline()) %>" />[/b]
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
</div>
</user>
The problem is that all users seems to be online, where they are not! Why is that happening? Am i doing something wrong?