Foros de discusión

<liferay-ui:search-container> pagination problem

thumbnail
Scott Rabon, modificado hace 13 años.

<liferay-ui:search-container> pagination problem

Junior Member Mensajes: 48 Fecha de incorporación: 15/04/10 Mensajes recientes
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:


<liferay-ui:search-container iteratorurl="${colorIteratorURL}" emptyresultsmessage="colorEmptyResultsMessage" delta="15">
	<liferay-ui:search-container-results>
		&lt;%
			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);
		%&gt;
	</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
thumbnail
Sandeep Nair, modificado hace 13 años.

RE: <liferay-ui:search-container> pagination problem

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
Hi,

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

Regards,
Sandeep
thumbnail
Scott Rabon, modificado hace 13 años.

RE: <liferay-ui:search-container> pagination problem

Junior Member Mensajes: 48 Fecha de incorporación: 15/04/10 Mensajes recientes
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:


&lt;%
	PortletURL colorIteratorURL = renderResponse.createActionURL();
	colorIteratorURL.setParameter("javax.portlet.action", "findColors");
	colorIteratorURL.setParameter("searchTerm", "blue");
	colorIteratorURL.setParameter("searchBy", "colorName");
	pageContext.setAttribute("colorIteratorURL", colorIteratorURL);
%&gt;
<liferay-ui:search-container iteratorurl="${colorIteratorURL}" emptyresultsmessage="colorEmptyResultsMessage" delta="15">
	<liferay-ui:search-container-results>
		&lt;%
			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);
		%&gt;
	</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
thumbnail
Sandeep Nair, modificado hace 13 años.

RE: <liferay-ui:search-container> pagination problem

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
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
thumbnail
Scott Rabon, modificado hace 13 años.

RE: <liferay-ui:search-container> pagination problem

Junior Member Mensajes: 48 Fecha de incorporación: 15/04/10 Mensajes recientes
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
thumbnail
Chris Newton, modificado hace 13 años.

RE: <liferay-ui:search-container> pagination problem

New Member Mensajes: 2 Fecha de incorporación: 20/07/10 Mensajes recientes
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.
thumbnail
Luis Rodríguez Fernández, modificado hace 13 años.

RE: <liferay-ui:search-container> pagination problem

Junior Member Mensajes: 86 Fecha de incorporación: 26/06/09 Mensajes recientes
Hi Chris,

It works!!!

Thanks a lot,

Luis
Claudiu Faur, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

New Member Mensajes: 11 Fecha de incorporación: 28/05/11 Mensajes recientes
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.

&lt;%
	PortletURL itURL = renderResponse.createRenderURL();
%&gt;
<liferay-ui:search-container emptyresultsmessage="there-are-no-people" delta="5" iteratorurl="<%= itURL %>">
	<liferay-ui:search-container-results>
	    &lt;%
	    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);
	    %&gt;
. ...
</people></liferay-ui:search-container-results></liferay-ui:search-container>
thumbnail
Sandeep Nair, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
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
thumbnail
Kamesh Sampath, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Regular Member Mensajes: 158 Fecha de incorporación: 27/05/10 Mensajes recientes
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,
<liferay-ui:search-container emptyresultsmessage="there-are-no-files" delta="5">
				<liferay-ui:search-container-results>

					&lt;%
					    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);
					%&gt;
				</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 ?
thumbnail
Hitesh Methani, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Regular Member Mensajes: 171 Fecha de incorporación: 24/06/10 Mensajes recientes
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
thumbnail
Kamesh Sampath, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Regular Member Mensajes: 158 Fecha de incorporación: 27/05/10 Mensajes recientes
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
thumbnail
Fabio Foglia, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Junior Member Mensajes: 61 Fecha de incorporación: 2/09/11 Mensajes recientes
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
thumbnail
Fabio Foglia, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Junior Member Mensajes: 61 Fecha de incorporación: 2/09/11 Mensajes recientes
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
thumbnail
Puj Z, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Regular Member Mensajes: 220 Fecha de incorporación: 14/01/10 Mensajes recientes
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
thumbnail
Kamesh Sampath, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Regular Member Mensajes: 158 Fecha de incorporación: 27/05/10 Mensajes recientes
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
thumbnail
Brian Jamieson, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Junior Member Mensajes: 51 Fecha de incorporación: 15/10/10 Mensajes recientes
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
thumbnail
Kamesh Sampath, modificado hace 12 años.

RE: <liferay-ui:search-container> pagination problem

Regular Member Mensajes: 158 Fecha de incorporación: 27/05/10 Mensajes recientes
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
thumbnail
Laura Liparulo, modificado hace 11 años.

RE: <liferay-ui:search-container> pagination problem

Junior Member Mensajes: 38 Fecha de incorporación: 30/06/12 Mensajes recientes