フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Jose Alvarez de Lara
portlet does not access table Liferay User
2012/12/27 23:16
答え

Jose Alvarez de Lara

ランク: Junior Member

投稿: 45

参加年月日: 2012/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,
 1
 2<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
 3<%@ include file="/html/init.jsp" %>
 4
 5<h4>Test User List</h4>
 6
 7<%
 8int count = UserLocalServiceUtil.getUsersCount();
 9List<User> users = UserLocalServiceUtil.getUsers(0, count);
10%>
11
12<%
13PortletURL iteratorURL = renderResponse.createRenderURL();
14iteratorURL.setParameter("jspPage", "/html/list.jsp");
15
16PortletURL updateUserURL = renderResponse.createActionURL();
17updateUserURL.setParameter("jspPage", "/html/update.jsp");
18
19PortletURL detailsURL = renderResponse.createRenderURL();
20detailsURL.setParameter("jspPage", "/html/details.jsp");
21%>
22
23<liferay-ui:search-container delta="4" iteratorURL="<%= iteratorURL %>"
24    emptyResultsMessage="Sorry. There are no items to display.">
25
26    <liferay-ui:search-container-results
27        total="<%= users.size() %>"
28        results="<%= ListUtil.subList(users, searchContainer.getStart(), searchContainer.getEnd()) %>"
29    />
30       
31    <liferay-ui:search-container-row modelVar="user"
32        className="com.liferay.portal.model.User">
33       
34        <%
35            detailsURL.setParameter("userId", String.valueOf(user.getUserId()));
36            detailsURL.setParameter("backURL", themeDisplay.getURLCurrent());
37        %>
38        <liferay-ui:search-container-column-text name="User Full Name">
39            <aui:a href="<%= detailsURL.toString() %>"><%= user.getFullName() %></aui:a>
40        </liferay-ui:search-container-column-text>
41       
42        <% updateUserURL.setParameter("userId", String.valueOf(user.getUserId())); %>
43        <liferay-ui:search-container-column-text name="Update">
44            <a href="<%= updateUserURL.toString() %>">Update &raquo;</a>
45        </liferay-ui:search-container-column-text>
46       
47        <liferay-ui:search-container-column-jsp name="Actions"
48            path="/html/actions.jsp" />
49   
50    </liferay-ui:search-container-row>
51   
52    <liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
53
54</liferay-ui:search-container>
55
56<br/><a href="<portlet:renderURL/>">&laquo; Go Back</a>

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,
 1
 2<%@ include file="/html/init.jsp" %>
 3
 4Welcome to our Test User
 5
 6<%
 7    PortletURL listUsersURL = renderResponse.createRenderURL();
 8    listUsersURL.setParameter("jspPage", "/html/list.jsp");
 9%>
10
11<br/><a href="<%= listUsersURL.toString() %>">Show all users &raquo;</a>


Should be there some kind one who could help me.

Regards,
Jose
Jignesh Vachhani
RE: portlet does not access table Liferay User
2012/12/27 23:23
答え

Jignesh Vachhani

ランク: Liferay Master

投稿: 780

参加年月日: 2008/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.
Vishal Panchal
RE: portlet does not access table Liferay User
2012/12/27 23:26
答え

Vishal Panchal

ランク: Expert

投稿: 277

参加年月日: 2012/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
Jose Alvarez de Lara
RE: portlet does not access table Liferay User
2012/12/28 9:01
答え

Jose Alvarez de Lara

ランク: Junior Member

投稿: 45

参加年月日: 2012/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
Hitoshi Ozawa
RE: portlet does not access table Liferay User
2012/12/29 2:30
答え

Hitoshi Ozawa

ランク: Liferay Legend

投稿: 7990

参加年月日: 2010/03/23

最近の投稿

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.