Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Michael Bravo
Pagination issue using Search Container
March 14, 2013 6:47 PM
Answer

Michael Bravo

Rank: New Member

Posts: 20

Join Date: April 26, 2012

Recent Posts

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:

 1
 2<%@include file="/admin/init.jsp" %>
 3
 4
 5<%
 6PortletURL listOrdersURL = renderResponse.createRenderURL();
 7listOrdersURL.setParameter("jspPage", "/admin/display_orders.jsp");
 8%>
 9<a href="<%= listOrdersURL.toString() %>">Show all orders &raquo;</a>
10
11<br><br>
12
13<liferay-ui:search-container emptyResultsMessage="there-are-no-order-items" delta="5">
14  <liferay-ui:search-container-results>
15  <%
16 
17  int count = SOOrderItemsLocalServiceUtil.getSOOrderItemsesCount();
18  List<SOOrderItems> tempResults = SOOrderItemsLocalServiceUtil.getSOOrderItemses(0, count);
19  results = ListUtil.subList(tempResults, searchContainer.getStart(), searchContainer.getEnd());;
20  total = tempResults.size();
21
22  pageContext.setAttribute("results", results);
23  pageContext.setAttribute("total", total);
24 
25 
26  %>
27  </liferay-ui:search-container-results>
28
29  <liferay-ui:search-container-row
30      className="com.emory.supplies.model.SOOrderItems"
31      keyProperty="orderItemId"
32      modelVar="orderItem">
33
34    <liferay-ui:search-container-column-text
35        name="order-item-id"
36        property="orderItemId" />
37    <liferay-ui:search-container-column-text
38        name="order-id"
39        property="orderId" />
40    <liferay-ui:search-container-column-text
41      name="items-no"
42      property="itemsNo" />
43    <liferay-ui:search-container-column-text
44      name="page-no"
45      property="pageNo" />
46    <liferay-ui:search-container-column-text
47      name="description"
48      property="description" />
49    <liferay-ui:search-container-column-text
50      name="quantity"
51      property="quantity" />
52    <liferay-ui:search-container-column-text
53      name="net-price"
54      property="netPrice" /> 
55    <liferay-ui:search-container-column-jsp 
56        path="/admin/display_actions.jsp"
57        align="right" />
58  </liferay-ui:search-container-row>
59
60  <liferay-ui:search-iterator/>
61
62</liferay-ui:search-container>


This is code from the second view:

 1
 2<%@include file="/admin/init.jsp" %>
 3
 4<liferay-ui:search-container  emptyResultsMessage="there-are-no-orders" delta="5">
 5  <liferay-ui:search-container-results>
 6  <%
 7
 8  int count = SOOrderLocalServiceUtil.getSOOrdersCount();
 9  List<SOOrder> tempResults = SOOrderLocalServiceUtil.getSOOrders(0, count);
10 
11  results = ListUtil.subList(tempResults, searchContainer.getStart(), searchContainer.getEnd());
12  total = tempResults.size();
13 
14  pageContext.setAttribute("results", results);
15  pageContext.setAttribute("total", total);
16  %>
17  </liferay-ui:search-container-results>
18
19  <liferay-ui:search-container-row
20      className="com.emory.supplies.model.SOOrder"
21      keyProperty="orderId"
22      modelVar="order">
23
24    <liferay-ui:search-container-column-text
25        name="order-id"
26        property="orderId" />
27    <liferay-ui:search-container-column-text
28        name="department-name"
29        property="departmentName" />
30    <liferay-ui:search-container-column-text
31      name="smart-key-number"
32      property="smartKeyNumber" />
33    <liferay-ui:search-container-column-text
34      name="requester-name"
35      property="requesterName" />
36    <liferay-ui:search-container-column-text
37      name="email-address"
38      property="emailAddress" />
39    <liferay-ui:search-container-column-text
40      name="phone-number"
41      property="phoneNumber" />
42    <liferay-ui:search-container-column-text
43      name="room-number"
44      property="roomNumber" /> 
45    <liferay-ui:search-container-column-text
46      name="order-number"
47      property="orderNumber" />
48    <liferay-ui:search-container-column-text
49      name="email-sent"
50      property="emailSent" />      
51  </liferay-ui:search-container-row>
52
53  <liferay-ui:search-iterator />
54
55</liferay-ui:search-container>
Rahul Pande
RE: Pagination issue using Search Container
March 14, 2013 11:48 PM
Answer

Rahul Pande

Rank: Expert

Posts: 308

Join Date: July 6, 2010

Recent Posts

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
Michael Bravo
RE: Pagination issue using Search Container
March 15, 2013 6:51 AM
Answer

Michael Bravo

Rank: New Member

Posts: 20

Join Date: April 26, 2012

Recent Posts

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...
Rahul Pande
RE: Pagination issue using Search Container
March 17, 2013 11:34 PM
Answer

Rahul Pande

Rank: Expert

Posts: 308

Join Date: July 6, 2010

Recent Posts

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
Attachments: test-portlet-6.0.6.1.war (50.5k)
Michael Bravo
RE: Pagination issue using Search Container
March 18, 2013 2:02 PM
Answer

Michael Bravo

Rank: New Member

Posts: 20

Join Date: April 26, 2012

Recent Posts

Hi Rahul,

Thanks for the reply and for the sample!

Best,
Michael
Michael Bravo
RE: Pagination issue using Search Container
March 18, 2013 6:23 PM
Answer

Michael Bravo

Rank: New Member

Posts: 20

Join Date: April 26, 2012

Recent Posts

Rahul,

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

~Michael