Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
<liferay-ui:search-container> pagination problem Scott Rabon September 1, 2010 5:27 PM
RE: <liferay-ui:search-container> pagination problem Sandeep Nair September 1, 2010 10:54 PM
RE: <liferay-ui:search-container> pagination problem Scott Rabon September 2, 2010 8:30 AM
RE: <liferay-ui:search-container> pagination problem Sandeep Nair September 3, 2010 3:23 AM
RE: <liferay-ui:search-container> pagination problem Scott Rabon September 10, 2010 11:50 AM
RE: <liferay-ui:search-container> pagination problem Chris Newton September 28, 2010 9:29 AM
RE: <liferay-ui:search-container> pagination problem Luis Rodríguez Fernández January 23, 2011 11:47 AM
RE: <liferay-ui:search-container> pagination problem Claudiu Faur June 10, 2011 11:33 AM
RE: <liferay-ui:search-container> pagination problem Sandeep Nair June 24, 2011 3:29 AM
RE: <liferay-ui:search-container> pagination problem Kamesh Sampath July 22, 2011 3:59 AM
RE: <liferay-ui:search-container> pagination problem Hitesh Methani July 24, 2011 1:36 PM
RE: <liferay-ui:search-container> pagination problem Kamesh Sampath July 25, 2011 9:08 AM
RE: <liferay-ui:search-container> pagination problem Fabio Foglia November 26, 2011 7:42 AM
RE: <liferay-ui:search-container> pagination problem Fabio Foglia November 28, 2011 3:47 AM
RE: <liferay-ui:search-container> pagination problem Puj Z September 6, 2011 10:11 AM
RE: <liferay-ui:search-container> pagination problem Kamesh Sampath September 10, 2011 6:26 AM
RE: <liferay-ui:search-container> pagination problem Brian Jamieson September 13, 2011 10:16 AM
RE: <liferay-ui:search-container> pagination problem Kamesh Sampath September 13, 2011 11:50 AM
RE: <liferay-ui:search-container> pagination problem Laura Liparulo January 29, 2013 3:41 AM
Scott Rabon
<liferay-ui:search-container> pagination problem
September 1, 2010 5:27 PM
Answer

Scott Rabon

Rank: Junior Member

Posts: 48

Join Date: April 15, 2010

Recent Posts

I'm using Liferay 6.0.5 and developing a new portlet that uses <liferay-ui:search-container> tag. However, the pagination doesn't work properly. If I click the next button the first page is always loaded. I can see that the page number (class variable _cur) never changes in com.liferay.portal.kernel.dao.search.SearchContainer.java. Therefore, the calls to searchContainer.getStart() and getEnd() always return 0 and 15 (the delta). I don't see a way to set the current page from a property either. The only way to set this value is through the constructor, so how to do it only using the jsp tag? Here's my code:

 1
 2<liferay-ui:search-container iteratorURL="${colorIteratorURL}"
 3        emptyResultsMessage="colorEmptyResultsMessage" delta="15">
 4    <liferay-ui:search-container-results>
 5        <%
 6            List<Color> colors = (List<Color>)request.getAttribute("colors");
 7            results = ListUtil.subList(colors, searchContainer.getStart(), searchContainer.getEnd());
 8            total = colors.size();
 9   
10            pageContext.setAttribute("results", results);
11            pageContext.setAttribute("total", total);
12        %>
13    </liferay-ui:search-container-results>
14   
15    <liferay-ui:search-container-row
16          className="com.mascocoatings.portal.efb.model.Color"
17       keyProperty="colorId"
18       modelVar="color" >
19         
20         <liferay-ui:search-container-column-text
21              name="Color ID" property="colorCode" />
22      
23         <liferay-ui:search-container-column-text
24              name="Color Name" property="colorName" />
25    
26         <portlet:actionURL name="getProducts" var="productsURL">
27               <portlet:param name="colorId" value="<%=String.valueOf(color.getColorId())%>" />
28         </portlet:actionURL>
29         
30         <liferay-ui:search-container-column-text name=""
31                          href="${productsURL}" value="Get Products"/>
32                         
33    </liferay-ui:search-container-row>
34   
35    <liferay-ui:search-iterator/>
36</liferay-ui:search-container>


Thanks for your assistance,
Scott
Sandeep Nair
RE: <liferay-ui:search-container> pagination problem
September 1, 2010 10:54 PM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1692

Join Date: November 5, 2008

Recent Posts

Hi,

I am not sure but can you try removing this attribute iteratorURL="${colorIteratorURL}" from the tag

Regards,
Sandeep
Scott Rabon
RE: <liferay-ui:search-container> pagination problem
September 2, 2010 8:30 AM
Answer

Scott Rabon

Rank: Junior Member

Posts: 48

Join Date: April 15, 2010

Recent Posts

Thanks for your reply Sandeep. I originally didn't have the iteratorURL property in there. However, that caused problems, because the default iterator URL would just bring me back to my original view by calling the default doView() of my portlet with no parameters. So I added that property in there is so that I can call an action on my portlet that initializes the List<Color> object. Here's all the code together:

 1
 2<%
 3    PortletURL colorIteratorURL = renderResponse.createActionURL();
 4    colorIteratorURL.setParameter("javax.portlet.action", "findColors");
 5    colorIteratorURL.setParameter("searchTerm", "blue");
 6    colorIteratorURL.setParameter("searchBy", "colorName");
 7    pageContext.setAttribute("colorIteratorURL", colorIteratorURL);
 8%>
 9<liferay-ui:search-container iteratorURL="${colorIteratorURL}"
10        emptyResultsMessage="colorEmptyResultsMessage" delta="15">
11    <liferay-ui:search-container-results>
12        <%
13            List<Color> colors = (List<Color>)request.getAttribute("colors");
14            results = ListUtil.subList(colors, searchContainer.getStart(), searchContainer.getEnd());
15            total = colors.size();
16   
17            pageContext.setAttribute("results", results);
18            pageContext.setAttribute("total", total);
19        %>
20    </liferay-ui:search-container-results>
21   
22    <liferay-ui:search-container-row
23          className="com.mascocoatings.portal.efb.model.Color"
24       keyProperty="colorId"
25       modelVar="color" >
26         
27         <liferay-ui:search-container-column-text
28              name="Color ID" property="colorCode" />
29      
30         <liferay-ui:search-container-column-text
31              name="Color Name" property="colorName" />
32    
33         <portlet:actionURL name="getProducts" var="productsURL">
34               <portlet:param name="colorId" value="<%=String.valueOf(color.getColorId())%>" />
35         </portlet:actionURL>
36         
37         <liferay-ui:search-container-column-text name=""
38                          href="${productsURL}" value="Get Products"/>
39                         
40    </liferay-ui:search-container-row>
41   
42    <liferay-ui:search-iterator/>
43</liferay-ui:search-container>


In my portlet, I have an annotated method with @ProcessAction(name="findColors").

Scott
Sandeep Nair
RE: <liferay-ui:search-container> pagination problem
September 3, 2010 3:23 AM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1692

Join Date: November 5, 2008

Recent Posts

Hi Scott,

It should work ideally, but again a wild guess, try setting the delta to 10 or 25 since the default allowed values of delta are as follows

search.container.page.delta.values=5,10,20,30,50,75

Regards,
Sandeep
Scott Rabon
RE: <liferay-ui:search-container> pagination problem
September 10, 2010 11:50 AM
Answer

Scott Rabon

Rank: Junior Member

Posts: 48

Join Date: April 15, 2010

Recent Posts

That didn't seem to make a difference. The problem I see is that the current page doesn't get set. I got it working by using the Java classes directly and only using the <liferay-ui:search-iterator> tag after initializing all the objects. When I create my own SearchContainer object, I can pass in the current page using the correct constructor, which fixes the problem.

Scott
Chris Newton
RE: <liferay-ui:search-container> pagination problem
September 28, 2010 9:29 AM
Answer

Chris Newton

Rank: New Member

Posts: 2

Join Date: July 20, 2010

Recent Posts

I had exactly the same problem today. The problem was caused by the iteratorURL. Just like yourself, I initially created the iteratorURL using renderResponse.createActionURL() instead of renderResponse.createRenderURL(). It seems that some of the scoped variables required by the searchcontainer were lost during the redirect caused by using an actionURL.

In short, use renderResponse.createRenderURL() instead of renderResponse.createActionURL() to create your iteratorURL.


Hope this helps.
Luis Rodríguez Fernández
RE: <liferay-ui:search-container> pagination problem
January 23, 2011 11:47 AM
Answer

Luis Rodríguez Fernández

Rank: Junior Member

Posts: 86

Join Date: June 26, 2009

Recent Posts

Hi Chris,

It works!!!

Thanks a lot,

Luis
Claudiu Faur
RE: <liferay-ui:search-container> pagination problem
June 10, 2011 11:33 AM
Answer

Claudiu Faur

Rank: New Member

Posts: 11

Join Date: May 28, 2011

Recent Posts

Hi,

I have a similar problem. Everytime i use the next or previous button from my portlet, it redirects to the view.jsp page.
This is how my code looks like, if anyone can help me.
Thanks in advance.
 1
 2<%
 3    PortletURL itURL = renderResponse.createRenderURL();
 4%>
 5<liferay-ui:search-container emptyResultsMessage="there-are-no-people" delta="5" iteratorURL="<%= itURL %>" >
 6    <liferay-ui:search-container-results>
 7        <%
 8        List<People> tempResults = ActionUtil.getPeople(renderRequest);
 9   
10        results = ListUtil.subList(tempResults, searchContainer.getStart(), searchContainer.getEnd());
11        total = tempResults.size();
12   
13        pageContext.setAttribute("results", results);
14        pageContext.setAttribute("total", total);
15        %>
16. ...
Sandeep Nair
RE: <liferay-ui:search-container> pagination problem
June 24, 2011 3:29 AM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1692

Join Date: November 5, 2008

Recent Posts

I dont think you nee portlet url. Just use the one below

<liferay-ui:search-container emptyResultsMessage="there-are-no-people" delta="5" >

Remove iteratorURL

Regards,
Sandeep
Kamesh Sampath
RE: <liferay-ui:search-container> pagination problem
July 22, 2011 3:59 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

Hey Sandeep,
Hope you are doing good, I am facing the a similar problem with the search container, the pagination component is not displayed emoticon, find below the code snippet for the same,
 1<liferay-ui:search-container emptyResultsMessage="there-are-no-files"
 2                delta="5">
 3                <liferay-ui:search-container-results>
 4
 5                    <%
 6                        List<WebContentFileModel> listOfFiles = FileWebContentServiceUtil
 7                                        .getWebContentFiles(renderRequest);
 8                                    results = ListUtil.subList(listOfFiles,
 9                                        searchContainer.getStart(),
10                                        searchContainer.getEnd());
11                                    total = results.size();
12                                    pageContext.setAttribute("results", results);
13                                    pageContext.setAttribute("total", total);
14                    %>
15                </liferay-ui:search-container-results>
16
17                <liferay-ui:search-container-row
18                    className="com.accenture.icos.lpssv2.model.WebContentFileModel"
19                    keyProperty="webContentFile" modelVar="webContentFileModel">
20
21                    <liferay-ui:search-container-column-text name="web-content-title"
22                        property="webContentTitle" />
23                    <liferay-ui:search-container-column-text name="web-content-file"
24                        property="webContentFile" />
25                    <liferay-ui:search-container-column-jsp
26                        path="/WEB-INF/views/html/jsp/filewebcontentdisplay/searchActions.jsp"
27                        align="right" />
28
29                </liferay-ui:search-container-row>
30
31                <liferay-ui:search-iterator/>
32
33   
34   
35            </liferay-ui:search-container>

Though my search returns 14 records, the list always displays only 5 and not pagination is displayed.
Can you please let me know anything i missed which is preventing the content being displayed ?
Hitesh Methani
RE: <liferay-ui:search-container> pagination problem
July 24, 2011 1:36 PM
Answer

Hitesh Methani

Rank: Regular Member

Posts: 169

Join Date: June 24, 2010

Recent Posts

Hi Kamesh,

I think the problem lies with total = results.size();
instead of total = results.size(), you can try total = listOfFiles.size(), because results will always have size 5, that is equal to delta.
Actual total should be set to size of listOfFiles.

Hope this will help you out.

Thanks,
Hitesh
Kamesh Sampath
RE: <liferay-ui:search-container> pagination problem
July 25, 2011 9:08 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

thanks hitesh will try the same and let you know, a matter of fact am now using the SearchContainer approach found in various Liferay search pages.

Thanks.
Kamesh
Puj Z
RE: <liferay-ui:search-container> pagination problem
September 6, 2011 10:11 AM
Answer

Puj Z

Rank: Regular Member

Posts: 200

Join Date: January 14, 2010

Recent Posts

Hi guys,

sorry to ask my question here, but this post looked the most appropriate for my problem.
I want to change the background color of the rows of searchcontainer (liferay-ui:search-container-column-text) based on the value of the entity shown in that row. For that I need to add a custom class, but I don't know how. Has anyone any ideas how I can do that?
(for example, if an attribute of a row is more than 10, I want it to have blue background, if less that 10, I want it to be red, and stuff like that)

thank for any hint in advance!
Cheers,
Puj
Kamesh Sampath
RE: <liferay-ui:search-container> pagination problem
September 10, 2011 6:26 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

i did post a small customization of [url="http://www.liferay.com/community/forums/-/message_boards/message/10120863"] Search and Pagination

Also addressing your problem directly, once you deploy the portlet try to edit using "Look and Feel" option and add the necessary customization, for that you need to grab the css class for the the same which you can do using tools like Firebug installed in Firefox.

Hope this helps you.

~Kamesh
Brian Jamieson
RE: <liferay-ui:search-container> pagination problem
September 13, 2011 10:16 AM
Answer

Brian Jamieson

Rank: Junior Member

Posts: 51

Join Date: October 15, 2010

Recent Posts

Hi Puj Z

Did you ever get what you were looking for?

I examined the Control-Panel Update Manager portlet to see how they did the green, amber, red stuff there - it was a programmatically created search container.

I tried adding my own css rules, but the standard mouse-outs, and mouse-overs scuppered me.

Puj Z:
Hi guys,

sorry to ask my question here, but this post looked the most appropriate for my problem.
I want to change the background color of the rows of searchcontainer (liferay-ui:search-container-column-text) based on the value of the entity shown in that row. For that I need to add a custom class, but I don't know how. Has anyone any ideas how I can do that?
(for example, if an attribute of a row is more than 10, I want it to have blue background, if less that 10, I want it to be red, and stuff like that)

thank for any hint in advance!
Cheers,
Puj
Kamesh Sampath
RE: <liferay-ui:search-container> pagination problem
September 13, 2011 11:50 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

1. did you check my thread reply couple of messages ago i did make a fair bit of customization with SearchContainer. Please visit that page if that can help somehow.

2. use tools like firebug and try to capture the css stule used for the pagination stuff, then use my small how -to customize and apply the styles.

3. You can also dynamically execute a js script to grab the no of rows and apply your class using the Alloy UI API methods.

Hope i had given some pointers or directions for the same. let me know if you require any further help.

~Kamesh
Fabio Foglia
RE: <liferay-ui:search-container> pagination problem
November 26, 2011 7:42 AM
Answer

Fabio Foglia

Rank: Junior Member

Posts: 61

Join Date: September 2, 2011

Recent Posts

Scott Rabon:
That didn't seem to make a difference. The problem I see is that the current page doesn't get set. I got it working by using the Java classes directly and only using the <liferay-ui:search-iterator> tag after initializing all the objects. When I create my own SearchContainer object, I can pass in the current page using the correct constructor, which fixes the problem.

Scott



Hi Scott,

can you explain the way from starting from Action you tagged as @ProcessAction(name="findColors").

My problem is that the search container is not in view.jsp so paging didn't work and go to view.jsp.

Have you found a solution?

Thanks

Fabio
Fabio Foglia
RE: <liferay-ui:search-container> pagination problem
November 28, 2011 3:47 AM
Answer

Fabio Foglia

Rank: Junior Member

Posts: 61

Join Date: September 2, 2011

Recent Posts

Found a solution to pagination on page different from view.jsp , see my post on:

http://www.liferay.com/community/forums/-/message_boards/message/11596636
Laura Liparulo
RE: <liferay-ui:search-container> pagination problem
January 29, 2013 3:41 AM
Answer

Laura Liparulo

Rank: Junior Member

Posts: 38

Join Date: June 30, 2012

Recent Posts

Take a look at my solution:
http://www.liferay.com/community/forums/-/message_boards/message/21031639