Fórum

liferay-ui:search-container pagination does not work

thumbnail
Lucas Terra, modificado 8 Anos atrás.

liferay-ui:search-container pagination does not work

New Member Postagens: 5 Data de Entrada: 21/09/15 Postagens Recentes
Hi guys,

I developed a liferay-ui:search-container, but pagination does not work, the page always lists all records, and on page appears that this listing only 20.


		<liferay-ui:search-container delta="20" emptyresultsmessage="<liferay-ui:message key=&quot;com.test.portlet.searchClient.noResults&quot;/>">		
			<liferay-ui:search-container-results results="<%= (List<User>) renderRequest.getAttribute(&quot;listUsers&quot;) %>" total="<%= (Integer)renderRequest.getAttribute(&quot;countUsers&quot;) %>" /> 
			
				<liferay-ui:search-container-row classname="com.liferay.portal.model.User" modelvar="user" escapedmodel="<%= true %>">
					
					<liferay-ui:search-container-column-text name="Primeiro Nome" value="<%= user.getFirstName() %>" />	
					<liferay-ui:search-container-column-text name="Último Nome" value="<%=user.getLastName() %>" />
					<liferay-ui:search-container-column-text name="Nome de Exibição" value="<%=user.getScreenName() %>" />
					<liferay-ui:search-container-column-text name="Cargo" value="<%=user.getJobTitle() %>" />
					<liferay-ui:search-container-column-jsp align="right" path="/html/action.jsp" />
					
				</liferay-ui:search-container-row>			
			<liferay-ui:search-iterator paginate="<%= true %>" />
		</liferay-ui:search-container>


I've tried removing
paginate="&lt;%= true %&gt;"
, but not resolved.

someone has gone through this?

Thank's
thumbnail
Arun Das, modificado 8 Anos atrás.

RE: liferay-ui:search-container pagination does not work

Regular Member Postagens: 166 Data de Entrada: 23/07/12 Postagens Recentes
Hi,
Try to replace results='<%= (List<User>) renderRequest.getAttribute("listUsers") %>' with
results='<%=ListUtil.subList((List<User>) renderRequest.getAttribute("listUsers"), searchContainer.getStart(), searchContainer.getEnd()) %>'
in your liferay-ui:search-container tag

HTH
Arun
thumbnail
Lucas Terra, modificado 8 Anos atrás.

RE: liferay-ui:search-container pagination does not work (Resposta)

New Member Postagens: 5 Data de Entrada: 21/09/15 Postagens Recentes
Arun Das:
Hi,
Try to replace results='<%= (List<User>) renderRequest.getAttribute("listUsers") %>' with
results='<%=ListUtil.subList((List<User>) renderRequest.getAttribute("listUsers"), searchContainer.getStart(), searchContainer.getEnd()) %>'
in your liferay-ui:search-container tag

HTH
Arun


Thank you!! It worked in the first list . But when I click next , it happens a submit in view and consequently the list is empty.
This should happen as I make my list dynamically only when I click on my button get followed and a text field with the information.

Lucas
thumbnail
Arun Das, modificado 8 Anos atrás.

RE: liferay-ui:search-container pagination does not work

Regular Member Postagens: 166 Data de Entrada: 23/07/12 Postagens Recentes
Hi,
The list is empty because you get the list from renderRequest and it might be empty when the view was rendered (not sure until see complete code) . Please have a look on Liferay Pagination at this link. Quite well explained by the Author and even got example portlets.

HTH
Arun
thumbnail
Lucas Terra, modificado 8 Anos atrás.

RE: liferay-ui:search-container pagination does not work

New Member Postagens: 5 Data de Entrada: 21/09/15 Postagens Recentes
Arun Das:
Hi,
The list is empty because you get the list from renderRequest and it might be empty when the view was rendered (not sure until see complete code) . Please have a look on Liferay Pagination at this link. Quite well explained by the Author and even got example portlets.

HTH
Arun



Hi Arun I managed to solve. When I clicked next he made a new request and lost my view search parameters in renderRequest, to solve I put my parameters in the portlet session scope , not to lose in this way , he managed to hold the search again by clicking next .

example:
in processAction:

PortletSession session = actionRequest.getPortletSession();
session.setAttribute("filter","attribute-value", PortletSession.PORTLET_SCOPE);

in render:

String filter = (String) renderRequest.getPortletSession().getAttribute("filter");

Thank you so much!
thumbnail
Kailash Yadav, modificado 8 Anos atrás.

RE: liferay-ui:search-container pagination does not work (Resposta)

Regular Member Postagens: 211 Data de Entrada: 18/10/11 Postagens Recentes
As Arun said you need to pas two parameter:
1 - List of Model which you want to show on current page. This list should not be all objects. For eg. if you are on page 1, list should have record 1 to 10; if you are on page 2, list should have record 11 to 20 and so on.
2 - Total record - It used to generate pagination. For eg. if you have 25 records in DB and delta is 10, there will 3 page in pagination.

searchContainer.getStart() gives start position of records on that page
searchContainer.getEnd() gives end position of records on that page
thumbnail
pramod kumara, modificado 7 Anos atrás.

RE: liferay-ui:search-container pagination does not work

Junior Member Postagens: 54 Data de Entrada: 29/08/16 Postagens Recentes
hi

create one iteratorurl which points to same display page only
and pass one attribute containing that url in liferay ui search container tag

like <liferay-ui:search-container iteratorURL="<%=iteratorURL%>" delta="2"
emptyResultsMessage="Sorry. There are no items to display.">


total="<%= cpaneldetails.size() %>"
results="<%= ListUtil.subList(cpaneldetails,searchContainer.getStart(),searchContainer.getEnd()) %>" />


here cpaneldetails is the object u created and listing

cpaneldetails = CpaneldetailsLocalServiceUtil.findCpaneldetailsByExitUser(userId, -1, -1);