掲示板

portlet does not access table Liferay User

thumbnail
11年前 に Jose Alvarez de Lara によって更新されました。

portlet does not access table Liferay User

Junior Member 投稿: 45 参加年月日: 12/12/10 最新の投稿
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
11年前 に Jignesh Vachhani によって更新されました。

RE: portlet does not access table Liferay User

Liferay Master 投稿: 803 参加年月日: 08/03/10 最新の投稿
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
11年前 に Vishal Panchal によって更新されました。

RE: portlet does not access table Liferay User

Expert 投稿: 289 参加年月日: 12/05/20 最新の投稿
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
11年前 に Jose Alvarez de Lara によって更新されました。

RE: portlet does not access table Liferay User

Junior Member 投稿: 45 参加年月日: 12/12/10 最新の投稿
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
11年前 に Hitoshi Ozawa によって更新されました。

RE: portlet does not access table Liferay User

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
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.