Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Jose Alvarez de Lara
portlet does not access table Liferay User
27 dicembre 2012 23.16
Risposta

Jose Alvarez de Lara

Punteggio: Junior Member

Messaggi: 45

Data di Iscrizione: 10 dicembre 2012

Messaggi recenti

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
27 dicembre 2012 23.23
Risposta

Jignesh Vachhani

Punteggio: Liferay Master

Messaggi: 785

Data di Iscrizione: 10 marzo 2008

Messaggi recenti

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
27 dicembre 2012 23.26
Risposta

Vishal Panchal

Punteggio: Expert

Messaggi: 280

Data di Iscrizione: 20 maggio 2012

Messaggi recenti

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
28 dicembre 2012 9.01
Risposta

Jose Alvarez de Lara

Punteggio: Junior Member

Messaggi: 45

Data di Iscrizione: 10 dicembre 2012

Messaggi recenti

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
29 dicembre 2012 2.30
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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.