Fórumok
<liferay-ui:search-container> pagination problem
Scott Rabon, módosítva 13 év-val korábban
<liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 48 Csatlakozás dátuma: 2010.04.15. Legújabb bejegyzések
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:
Thanks for your assistance,
Scott
<liferay-ui:search-container iteratorurl="${colorIteratorURL}" emptyresultsmessage="colorEmptyResultsMessage" delta="15">
<liferay-ui:search-container-results>
<%
List<color> colors = (List<color>)request.getAttribute("colors");
results = ListUtil.subList(colors, searchContainer.getStart(), searchContainer.getEnd());
total = colors.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</color></color></liferay-ui:search-container-results>
<liferay-ui:search-container-row classname="com.mascocoatings.portal.efb.model.Color" keyproperty="colorId" modelvar="color">
<liferay-ui:search-container-column-text name="Color ID" property="colorCode" />
<liferay-ui:search-container-column-text name="Color Name" property="colorName" />
<portlet:actionurl name="getProducts" var="productsURL">
<portlet:param name="colorId" value="<%=String.valueOf(color.getColorId())%>" />
</portlet:actionurl>
<liferay-ui:search-container-column-text name="" href="${productsURL}" value="Get Products" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
Thanks for your assistance,
Scott
Sandeep Nair, módosítva 13 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
Hi,
I am not sure but can you try removing this attribute iteratorURL="${colorIteratorURL}" from the tag
Regards,
Sandeep
I am not sure but can you try removing this attribute iteratorURL="${colorIteratorURL}" from the tag
Regards,
Sandeep
Scott Rabon, módosítva 13 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 48 Csatlakozás dátuma: 2010.04.15. Legújabb bejegyzések
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:
In my portlet, I have an annotated method with @ProcessAction(name="findColors").
Scott
<%
PortletURL colorIteratorURL = renderResponse.createActionURL();
colorIteratorURL.setParameter("javax.portlet.action", "findColors");
colorIteratorURL.setParameter("searchTerm", "blue");
colorIteratorURL.setParameter("searchBy", "colorName");
pageContext.setAttribute("colorIteratorURL", colorIteratorURL);
%>
<liferay-ui:search-container iteratorurl="${colorIteratorURL}" emptyresultsmessage="colorEmptyResultsMessage" delta="15">
<liferay-ui:search-container-results>
<%
List<color> colors = (List<color>)request.getAttribute("colors");
results = ListUtil.subList(colors, searchContainer.getStart(), searchContainer.getEnd());
total = colors.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</color></color></liferay-ui:search-container-results>
<liferay-ui:search-container-row classname="com.mascocoatings.portal.efb.model.Color" keyproperty="colorId" modelvar="color">
<liferay-ui:search-container-column-text name="Color ID" property="colorCode" />
<liferay-ui:search-container-column-text name="Color Name" property="colorName" />
<portlet:actionurl name="getProducts" var="productsURL">
<portlet:param name="colorId" value="<%=String.valueOf(color.getColorId())%>" />
</portlet:actionurl>
<liferay-ui:search-container-column-text name="" href="${productsURL}" value="Get Products" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
In my portlet, I have an annotated method with @ProcessAction(name="findColors").
Scott
Sandeep Nair, módosítva 13 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
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
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, módosítva 13 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 48 Csatlakozás dátuma: 2010.04.15. Legújabb bejegyzések
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
Scott
Chris Newton, módosítva 13 év-val korábban
RE: <liferay-ui:search-container> pagination problem
New Member Bejegyzések: 2 Csatlakozás dátuma: 2010.07.20. Legújabb bejegyzések
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.
In short, use renderResponse.createRenderURL() instead of renderResponse.createActionURL() to create your iteratorURL.
Hope this helps.
Luis Rodríguez Fernández, módosítva 13 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 86 Csatlakozás dátuma: 2009.06.26. Legújabb bejegyzések
Hi Chris,
It works!!!
Thanks a lot,
Luis
It works!!!
Thanks a lot,
Luis
Claudiu Faur, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
New Member Bejegyzések: 11 Csatlakozás dátuma: 2011.05.28. Legújabb bejegyzések
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.
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.
<%
PortletURL itURL = renderResponse.createRenderURL();
%>
<liferay-ui:search-container emptyresultsmessage="there-are-no-people" delta="5" iteratorurl="<%= itURL %>">
<liferay-ui:search-container-results>
<%
List<people> tempResults = ActionUtil.getPeople(renderRequest);
results = ListUtil.subList(tempResults, searchContainer.getStart(), searchContainer.getEnd());
total = tempResults.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
. ...
</people></liferay-ui:search-container-results></liferay-ui:search-container>
Sandeep Nair, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
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
<liferay-ui:search-container emptyResultsMessage="there-are-no-people" delta="5" >
Remove iteratorURL
Regards,
Sandeep
Kamesh Sampath, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Regular Member Bejegyzések: 158 Csatlakozás dátuma: 2010.05.27. Legújabb bejegyzések
Hey Sandeep,
Hope you are doing good, I am facing the a similar problem with the search container, the pagination component is not displayed , find below the code snippet for the same,
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 ?
Hope you are doing good, I am facing the a similar problem with the search container, the pagination component is not displayed , find below the code snippet for the same,
<liferay-ui:search-container emptyresultsmessage="there-are-no-files" delta="5">
<liferay-ui:search-container-results>
<%
List<webcontentfilemodel> listOfFiles = FileWebContentServiceUtil
.getWebContentFiles(renderRequest);
results = ListUtil.subList(listOfFiles,
searchContainer.getStart(),
searchContainer.getEnd());
total = results.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</webcontentfilemodel></liferay-ui:search-container-results>
<liferay-ui:search-container-row classname="com.accenture.icos.lpssv2.model.WebContentFileModel" keyproperty="webContentFile" modelvar="webContentFileModel">
<liferay-ui:search-container-column-text name="web-content-title" property="webContentTitle" />
<liferay-ui:search-container-column-text name="web-content-file" property="webContentFile" />
<liferay-ui:search-container-column-jsp path="/WEB-INF/views/html/jsp/filewebcontentdisplay/searchActions.jsp" align="right" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</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, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Regular Member Bejegyzések: 171 Csatlakozás dátuma: 2010.06.24. Legújabb bejegyzések
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
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, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Regular Member Bejegyzések: 158 Csatlakozás dátuma: 2010.05.27. Legújabb bejegyzések
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
Thanks.
Kamesh
Fabio Foglia, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 61 Csatlakozás dátuma: 2011.09.02. Legújabb bejegyzésekScott 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, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 61 Csatlakozás dátuma: 2011.09.02. Legújabb bejegyzések
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
http://www.liferay.com/community/forums/-/message_boards/message/11596636
Puj Z, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Regular Member Bejegyzések: 220 Csatlakozás dátuma: 2010.01.14. Legújabb bejegyzések
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
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, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Regular Member Bejegyzések: 158 Csatlakozás dátuma: 2010.05.27. Legújabb bejegyzések
i did post a small customization of 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
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, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 51 Csatlakozás dátuma: 2010.10.15. Legújabb bejegyzések
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.
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, módosítva 12 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Regular Member Bejegyzések: 158 Csatlakozás dátuma: 2010.05.27. Legújabb bejegyzések
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
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
Laura Liparulo, módosítva 11 év-val korábban
RE: <liferay-ui:search-container> pagination problem
Junior Member Bejegyzések: 38 Csatlakozás dátuma: 2012.06.30. Legújabb bejegyzések
Take a look at my solution:
http://www.liferay.com/community/forums/-/message_boards/message/21031639
http://www.liferay.com/community/forums/-/message_boards/message/21031639