Foros de discusión

portlet does not access table Liferay User

thumbnail
Jose Alvarez de Lara, modificado hace 11 años.

portlet does not access table Liferay User

Junior Member Mensajes: 45 Fecha de incorporación: 10/12/12 Mensajes recientes
Merry Christmas everyone emoticon,

I have a portle that prettends to access the table _User, get a list of all user and in case
of a selected one can update the first and last name.

But it does not work. No error, simplely it does anything.
Here is the main jsp code in the list.jsp file,

<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@ include file="/html/init.jsp" %>

<h4>Test User List</h4>

&lt;%
int count = UserLocalServiceUtil.getUsersCount();
List<user> users = UserLocalServiceUtil.getUsers(0, count);
%&gt;

&lt;%
PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setParameter("jspPage", "/html/list.jsp");

PortletURL updateUserURL = renderResponse.createActionURL();
updateUserURL.setParameter("jspPage", "/html/update.jsp");

PortletURL detailsURL = renderResponse.createRenderURL();
detailsURL.setParameter("jspPage", "/html/details.jsp");
%&gt;

<liferay-ui:search-container delta="4" iteratorurl="<%= iteratorURL %>" emptyresultsmessage="Sorry. There are no items to display.">

	<liferay-ui:search-container-results total="<%= users.size() %>" results="<%= ListUtil.subList(users, searchContainer.getStart(), searchContainer.getEnd()) %>" />
		
	<liferay-ui:search-container-row modelvar="user" classname="com.liferay.portal.model.User">
		
		&lt;% 
			detailsURL.setParameter("userId", String.valueOf(user.getUserId()));
			detailsURL.setParameter("backURL", themeDisplay.getURLCurrent());
		%&gt;
		<liferay-ui:search-container-column-text name="User Full Name">
			<aui:a href="<%= detailsURL.toString() %>">&lt;%= user.getFullName() %&gt;</aui:a>
		</liferay-ui:search-container-column-text>
		
		&lt;% updateUserURL.setParameter("userId", String.valueOf(user.getUserId())); %&gt;
		<liferay-ui:search-container-column-text name="Update">
			<a href="<%= updateUserURL.toString() %>">Update »</a>
		</liferay-ui:search-container-column-text>
		
		<liferay-ui:search-container-column-jsp name="Actions" path="/html/actions.jsp" />
	
	</liferay-ui:search-container-row>
	
	<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />

</liferay-ui:search-container>

<br><a href="<portlet:renderURL/>">« Go Back</a>
</user>

it seems that exists an issue in the line,
<liferay-ui:search-container delta="4" iteratorURL="<%= iteratorURL %>"
emptyResultsMessage="Sorry. There are no items to display.">

I am not sure if delta="4" is correct. If someone could clear what it means
I shold be glad.

Here is the view.jsp file that causes no problem,

&lt;%@ include file="/html/init.jsp" %&gt;

Welcome to our Test User

&lt;%
	PortletURL listUsersURL = renderResponse.createRenderURL();
	listUsersURL.setParameter("jspPage", "/html/list.jsp");
%&gt;

<br><a href="<%= listUsersURL.toString() %>">Show all users »</a>


Should be there some kind one who could help me.

Regards,
Jose
thumbnail
Jignesh Vachhani, modificado hace 11 años.

RE: portlet does not access table Liferay User

Liferay Master Mensajes: 803 Fecha de incorporación: 10/03/08 Mensajes recientes
Please try to set delta 20 and check the result again.
Also please put SOP to see that users object & count variable have any data or not.
thumbnail
Vishal Panchal, modificado hace 11 años.

RE: portlet does not access table Liferay User

Expert Mensajes: 289 Fecha de incorporación: 20/05/12 Mensajes recientes
Hi ,

First of all in <liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found">

delta - The number of results per page.
you have set it to "4" so only four records will be displayed on page at the same time.

Now everything looks fine I am not sure why you are not getting anything.

Are you getting the emptyResultsMessage as you set it to "Sorry. There are no items to display."

I think it should be coming from language.properties file and you need to specify key.

Kindly go through this link .
Hope it helps.

Thanks&Regards,
Vishal R. Panchal
thumbnail
Jose Alvarez de Lara, modificado hace 11 años.

RE: portlet does not access table Liferay User

Junior Member Mensajes: 45 Fecha de incorporación: 10/12/12 Mensajes recientes
Thanks for your quick reply.

The problem is the default user with email address default@liferay.com.
It seems that exixts some cause wich the jsp file can't display that user for.

I have changed the code as follows,

int count = UserLocalServiceUtil.getUsersCount();
List<User> users = UserLocalServiceUtil.getUsers(1, count);

avoiding the default user and now it works fine.

Regards,
Jose
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: portlet does not access table Liferay User

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
Instead of
int count = UserLocalServiceUtil.getUsersCount();
List<User> users = UserLocalServiceUtil.getUsers(0, count);


Should be using
UserLocalServiceUtil.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS)

default@liferay.com user is probably causing some error because it's missing some required fields.

Also, are you sure you want to get all users because that will also return disabled users as well.
The better choice may be to use dynamicQuery() to select users to list.