Foros de discusión

Pagination not working in Liferay search container

Mrs Sindhu, modificado hace 7 años.

Pagination not working in Liferay search container

New Member Mensajes: 19 Fecha de incorporación: 28/07/16 Mensajes recientes
I have used Liferay search container to display records.

5 records per page .Loading page is working as expected but when i click next button its redirecting to the first page.Could anyone help me to solve my issue.

Attached is the code.

Archivos adjuntos:

Mrs Raghavan, modificado hace 7 años.

RE: Pagination not working in Liferay search container

New Member Mensajes: 19 Fecha de incorporación: 28/07/16 Mensajes recientes
could anybody please advice...I have tried all combinations.Not working.Am I missing anything???

<liferay-ui:search-container delta="<%=eventsHomePerPage %>" total="<%=viewSentbyCardName.size() %>" deltaConfigurable="true">


<liferay-ui:search-container-results>
<%
results = ListUtil.subList(viewSentbyCardName, searchContainer.getStart(), searchContainer.getResultEnd());
total = viewSentbyCardName.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>

<liferay-ui:search-container-row className="com.liferay.ecard.model.ecardsentheader" keyProperty="userId" modelVar="aecardsentheader">

<liferay-ui:search-container-column-text property="senderName" name="Sender Name"/>

<liferay-ui:search-container-column-text property="cardName" name="Card Name"/>



<%
SimpleDateFormat df = new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz yyyy");
%>
<liferay-ui:search-container-column-text name="Sent Date" value="<%=df.format(aecardsentheader.getSentDate()) %>" />

<%System.out.println("getCardName inside search container"+aecardsentheader.getCardName()); %>

<portlet:renderURL var="detail">
<portlet:param name="jspPage" value="/html/ecard/view_detail.jsp"></portlet:param>
<portlet:param name="hdnseleCardName" value="<%=aecardsentheader.getCardName()%>"></portlet:param>
<portlet:param name="hdnEcardFieldId" value="<%=String.valueOf(aecardsentheader.getEcardFileId())%>"></portlet:param>
<portlet:param name="hdnEcardGroupId" value="<%=String.valueOf(aecardsentheader.getGroupId())%>"></portlet:param>
<portlet:param name="hdnEcardSentDate" value="<%=String.valueOf(df.format(aecardsentheader.getSentDate()))%>"></portlet:param>
<portlet:param name="cmd" value="VIEWDETAIL"/>
</portlet:renderURL>

<liferay-ui:search-container-column-text name="View Detail" value="ViewDetail" href="<%=detail %>"/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator type="article"/>

</liferay-ui:search-container>
thumbnail
Gaurav Jain, modificado hace 7 años.

RE: Pagination not working in Liferay search container

Junior Member Mensajes: 85 Fecha de incorporación: 12/07/16 Mensajes recientes
Hi Mrs Raghavan,

I think you are missing iteratorURL inside liferay-ui:search-container. Check following snippet from /html/portlet/document_library_display/view.jsp


<liferay-ui:search-container curparam="cur1" delta="<%= foldersPerPage %>" deltaconfigurable="<%= false %>" headernames="<%= StringUtil.merge(folderColumns) %>" [b]iteratorurl="<%= portletURL %>" [ b] total="<%= foldersCount %>"></liferay-ui:search-container>


In this jsp portletURL, which is being used as iteratorURL, is created as:

PortletURL portletURL = renderResponse.createRenderURL();



For more, you can refer to any of liferay's jsp, which uses Liferay search container, to resolve your problems regarding Liferay search container.
Regards,
Gaurav
Mrs Raghavan, modificado hace 7 años.

RE: Pagination not working in Liferay search container

New Member Mensajes: 19 Fecha de incorporación: 28/07/16 Mensajes recientes
Hi Gaurav,

Yes I have even tried by setting iteratorURL , but its forwarding to an empty page without the values. Could anyone please advice ?????emoticon

<%
if(ecardSentObject!=null){
String cardFieldId="";
boolean flag = false;
String recName="";


System.out.println("inside ecardSentObject after changing to loop *&&&&&&&&&&&&&&&& *************");
System.out.println("ecardSentObject.getSenderName() after changing to loop**********"+eCardSentHeaderObject.getSenderName());
String cardName=eCardSentHeaderObject.getCardName();
PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setParameter("jspPage", "/html/ecard/view_sentCard.jsp");

%>
<liferay-ui:search-container curParam="cur" iteratorURL="<%= iteratorURL %>" delta="<%=eventsHomePerPage %>" emptyResultsMessage="NoSentItems" total="<%=ecardSentObject.size() %>" deltaConfigurable="true">

<liferay-ui:search-container-results>
<%
results = ListUtil.subList(ecardSentObject, searchContainer.getStart(), searchContainer.getResultEnd());
total = ecardSentObject.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
iteratorURL.setParameter("cur",searchContainer.getCurParam());
System.out.println("Cur PRINT***::::" + searchContainer.getCurParam());
%>
</liferay-ui:search-container-results>

<liferay-ui:search-container-row className="com.liferay.ecard.model.ecardsentheader" keyProperty="userId" modelVar="aecardsentheader">

<liferay-ui:search-container-column-text property="senderName" name="Sender Name"/>

<liferay-ui:search-container-column-text property="cardName" name="Card Name"/>



<%
SimpleDateFormat df = new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz yyyy");
%>
<liferay-ui:search-container-column-text name="Sent Date" value="<%=df.format(aecardsentheader.getSentDate()) %>" />

<%System.out.println("getCardName inside search container"+aecardsentheader.getCardName()); %>

<portlet:renderURL var="detail">
<portlet:param name="jspPage" value="/html/ecard/view_detail.jsp"></portlet:param>
<portlet:param name="hdnseleCardName" value="<%=aecardsentheader.getCardName()%>"></portlet:param>
<portlet:param name="hdnEcardFieldId" value="<%=String.valueOf(aecardsentheader.getEcardFileId())%>"></portlet:param>
<portlet:param name="hdnEcardGroupId" value="<%=String.valueOf(aecardsentheader.getGroupId())%>"></portlet:param>
<portlet:param name="hdnEcardSentDate" value="<%=String.valueOf(df.format(aecardsentheader.getSentDate()))%>"></portlet:param>
<portlet:param name="cmd" value="VIEWDETAIL"/>
</portlet:renderURL>

<liferay-ui:search-container-column-text name="View Detail" value="ViewDetail" href="<%=detail %>"/>



</liferay-ui:search-container-row>

<liferay-ui:search-iterator type="article"/>
</liferay-ui:search-container>
Mrs Raghavan, modificado hace 7 años.

RE: Pagination not working in Liferay search container

New Member Mensajes: 19 Fecha de incorporación: 28/07/16 Mensajes recientes
Do I need to set parameter for iteratorURL???

1. create renderUrl <% PortletURL iteratorURL = renderResponse.createRenderURL(); %>

2. modify the following line of code

<liferay-ui:search-container delta="2" emptyResultsMessage="no such user" iteratorURL="<%=iteratorURL%>">

3. Add the <liferay-ui:search-iterator /> tag

</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>

Please advice....