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?
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%>">
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.
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>