Foren

Pagination issue using Search Container

thumbnail
Michael Bravo, geändert vor 11 Jahren.

Pagination issue using Search Container

New Member Beiträge: 20 Beitrittsdatum: 26.04.12 Neueste Beiträge
Hi Folks,

I've got an issue regarding an Admin Portlet and pagination using Search Container.

I have a portlet with two view currently. One view displays fields from an 'Order Items' table. The second view displays fields from an 'Order' table.

The first view has a link to the second view -- 'Show all Orders' >>

The first time I hit the page, I see the table fine in the second view. I am viewing results of the fields in the 'Order' table as expected.

The issue occurs when I select 'Next' or the '2' in the pagination dropdown, the view is of the results from the 'OrderItems' table. The first page in the flow.

I believe it is a scope issue, but I am not certain.

Has anyone seen an issue similar to this?

Thanks in advance,
~Michael

This is code from the first page:


<%@include file="/admin/init.jsp" %>


<%
PortletURL listOrdersURL = renderResponse.createRenderURL();
listOrdersURL.setParameter("jspPage", "/admin/display_orders.jsp");
%>
<a href="<%= listOrdersURL.toString() %>">Show all orders »</a>

<br><br>

<liferay-ui:search-container emptyresultsmessage="there-are-no-order-items" delta="5">
  <liferay-ui:search-container-results>
  &lt;%
  
  int count = SOOrderItemsLocalServiceUtil.getSOOrderItemsesCount();
  List<soorderitems> tempResults = SOOrderItemsLocalServiceUtil.getSOOrderItemses(0, count);
  results = ListUtil.subList(tempResults, searchContainer.getStart(), searchContainer.getEnd());;
  total = tempResults.size();

  pageContext.setAttribute("results", results);
  pageContext.setAttribute("total", total);
  
  
  %&gt;
  </soorderitems></liferay-ui:search-container-results>

  <liferay-ui:search-container-row classname="com.emory.supplies.model.SOOrderItems" keyproperty="orderItemId" modelvar="orderItem">

    <liferay-ui:search-container-column-text name="order-item-id" property="orderItemId" />
    <liferay-ui:search-container-column-text name="order-id" property="orderId" />
    <liferay-ui:search-container-column-text name="items-no" property="itemsNo" />
    <liferay-ui:search-container-column-text name="page-no" property="pageNo" />
    <liferay-ui:search-container-column-text name="description" property="description" />
    <liferay-ui:search-container-column-text name="quantity" property="quantity" />
    <liferay-ui:search-container-column-text name="net-price" property="netPrice" />  
    <liferay-ui:search-container-column-jsp path="/admin/display_actions.jsp" align="right" />
  </liferay-ui:search-container-row>

  <liferay-ui:search-iterator />

</liferay-ui:search-container>


This is code from the second view:


&lt;%@include file="/admin/init.jsp" %&gt;

<liferay-ui:search-container emptyresultsmessage="there-are-no-orders" delta="5">
  <liferay-ui:search-container-results>
  &lt;%

  int count = SOOrderLocalServiceUtil.getSOOrdersCount();
  List<soorder> tempResults = SOOrderLocalServiceUtil.getSOOrders(0, count);
  
  results = ListUtil.subList(tempResults, searchContainer.getStart(), searchContainer.getEnd());
  total = tempResults.size();
  
  pageContext.setAttribute("results", results);
  pageContext.setAttribute("total", total);
  %&gt;
  </soorder></liferay-ui:search-container-results>

  <liferay-ui:search-container-row classname="com.emory.supplies.model.SOOrder" keyproperty="orderId" modelvar="order">

    <liferay-ui:search-container-column-text name="order-id" property="orderId" />
    <liferay-ui:search-container-column-text name="department-name" property="departmentName" />
    <liferay-ui:search-container-column-text name="smart-key-number" property="smartKeyNumber" />
    <liferay-ui:search-container-column-text name="requester-name" property="requesterName" />
    <liferay-ui:search-container-column-text name="email-address" property="emailAddress" />
    <liferay-ui:search-container-column-text name="phone-number" property="phoneNumber" />
    <liferay-ui:search-container-column-text name="room-number" property="roomNumber" />  
    <liferay-ui:search-container-column-text name="order-number" property="orderNumber" />
	<liferay-ui:search-container-column-text name="email-sent" property="emailSent" />      
  </liferay-ui:search-container-row>

  <liferay-ui:search-iterator />

</liferay-ui:search-container>
thumbnail
Rahul Pande, geändert vor 11 Jahren.

RE: Pagination issue using Search Container

Expert Beiträge: 310 Beitrittsdatum: 07.07.10 Neueste Beiträge
Hi Michael,

The description is little confusing emoticon . Can you please explain it again ?

However I have one question

Are you using these two search containers on same page ?
If Yes then in order to make both search containers work independently you have to create "iterator URL" with state (current parameter and delta) of each search container and use it for pagination


Thanks
Rahul
thumbnail
Michael Bravo, geändert vor 11 Jahren.

RE: Pagination issue using Search Container

New Member Beiträge: 20 Beitrittsdatum: 26.04.12 Neueste Beiträge
Hi Rahul,

The Search Containers are on different pages. Sorry if the explanation was confusing.

One page is called say view_1.jsp. It has one container that shows the fields in a table called 'OrderItems'.

The other page is called view_2.jsp. It has a searchContainer that shows the fields in a different table called 'Orders'

There are two db tables. One table is displayed on one of the jsps, while the other table is displayed on the second jsp.

I have link in the view_1.jsp that goes to view_2.jsp.

When I select the link, it takes me to the view_2.jsp as expected. I can view the table and it has the first 5 rows showing perfectly. The delta is set to 5 for the searchContainer.

The issue is when I select the 'Next' or page '2' in the pagination dropdown on view_2.jsp, the servlet container refreshes and returns me to the view_1.jsp set of results.

Thanks in advance...
thumbnail
Rahul Pande, geändert vor 11 Jahren.

RE: Pagination issue using Search Container

Expert Beiträge: 310 Beitrittsdatum: 07.07.10 Neueste Beiträge
Hi Michael,

Things are much clear now emoticon .

When you click next, select delta or page no from drop down list, then search container refreshes the page with your selected parameter value.

In this process it calls default render method for the portlet, that's the reason why you are going back to view_1.jsp.

If you want pagination on second page then you have to pass different URL to the search container using iteratorURL attribute.

As you said you have a link in the view_1.jsp that goes to view_2.jsp.


I guess to do this you have an <portlet:renderURL>, so use this URL as iterator url for search container on view_2.jsp and the pagination will work.

PFA sample portlet for your reference.

Thanks
Rahul
thumbnail
Michael Bravo, geändert vor 11 Jahren.

RE: Pagination issue using Search Container

New Member Beiträge: 20 Beitrittsdatum: 26.04.12 Neueste Beiträge
Hi Rahul,

Thanks for the reply and for the sample!

Best,
Michael
thumbnail
Michael Bravo, geändert vor 11 Jahren.

RE: Pagination issue using Search Container

New Member Beiträge: 20 Beitrittsdatum: 26.04.12 Neueste Beiträge
Rahul,

The solution worked perfectly. Thank you again for the help!

~Michael
thumbnail
Tejas Chandra Gowda, geändert vor 7 Jahren.

RE: Pagination issue using Search Container

New Member Beitrag: 1 Beitrittsdatum: 01.01.17 Neueste Beiträge
Hi Rahul,

I am new to Liferay Development, I am facing exactly same issue in Pagination, well in my case:

I am trying to fetch employee list from DB and while clicking "2" from the below pagination default render method is called.

You have given solution as to use Iterator URL in search container

Kindly be precised where and how to use that Iterator URL on jsp.

as I tried this by setting a session in Handler and fetching list of employee but inVAIN.