Liferay Search Container pagination

断了今生、忘了曾经 提交于 2019-12-10 20:18:36

问题


I have used liferay-ui:search-container in my code.

the search results are being displayed properly till i click on the NEXT. The portlet is being reloaded and that is taking me to the first page of the portlet, trashing the presented search results.

How do I retain the search results even after the portlet gets reloaded?


回答1:


You can give a value to the iteratorURL attribute if its default behaviour doesn't fit your needs.

In the following example when you click 'Next' on the search result table the proccesAction() method of the portlet will be invoked with param1 and param2.

You can add logic to that method to retain your search results.

<%
PortletURL urlPaginator=renderResponse.createActionURL();
urlPaginator.setParameter("param1", value1);
urlPaginator.setParameter("param2",value2);
%>

<liferay-ui:search-container iteratorURL="<%=urlPaginator%>">



回答2:


The liferay search container works on the parameters that you pass when click you click "next" and "previous".

Please observe the URL of the "next" and "previous" link.

For eg, the URL will have parameters like :

p_p_id=15&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&doAsGroupId=10194&refererPlid=12110&_15_struts_action=%2Fjournal%2Fview&_15_tabs1=templates&_15_delta=20&_15_keywords=&_15_advancedSearch=false&_15_andOperator=true&_15_description=&_15_groupIds=10194&_15_name=&_15_structureId=&_15_searchTemplateId=&_15_resetCur=false&cur=2

The Liferay search container uses delta, cur parameters to navigate to the next set of results.

For more information, just have a look at the liferay portlets which uses search containers and how they build the URLs.




回答3:


Clicking on NEXT (or any other paginator's button in search-container) cause a render of the portlet. If search-container is not in the first page of the portlet (usually view.jsp, set in your portlet.xml), you will be redirect there (default behavior of render phase).

In Liferay 6.2 you can set an iteratorUrl and specify, with parameter mvcPath, wich is your current jsp.

<liferay-portlet:renderURL portletConfiguration="true" varImpl="iteratorURL">
  <liferay-portlet:param name="mvcPath" value="something.jsp"/>
</liferay-portlet:renderURL>
<liferay-ui:search-container iteratorURL="<%=iteratorURL %>">
  [...]
</liferay-ui:search-container>


来源:https://stackoverflow.com/questions/15130292/liferay-search-container-pagination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!