Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Mario Muñoz
Pagination problem
August 11, 2008 3:06 AM

Mario Muñoz

Rank: Junior Member

Posts: 43

Join Date: August 27, 2007

Recent Posts

Hi everybody,

I'm developing a custom search portlet that must search within a list of courses. It's works fine, except when it displays the results of the search. I'm using the Liferay API trying to do the same that portal does in the source code, with SearchContainer and ResultRow classes. In the jsp that renders the results, I'm using the search-iterator tag with the attribute of pagination set to true.

The problem is that the pagination area shows correctly the number of results and the number of them that must be displayed whithin the table, but the table shows all the results. I include an image of the portlet for better understanding:


Does anybody have any tip?

I can give detailed information about the SearchContainer and ResultRow classes if needed.


Juan Fernández
RE: Pagination problem
January 27, 2009 8:59 AM

Juan Fernández


Rank: Liferay Legend

Posts: 1262

Join Date: October 2, 2008

Recent Posts

Here you have an easy example of how to use this:

SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, headerNames, LanguageUtil.format(pageContext, "no-documents-were-found-that-matched-the-keywords-x", "<b>" + keywords + "</b>"));

Hits hits =, portletGroupId, folderIdsArray, keywords);

Hits results = hits.subset(searchContainer.getStart(), searchContainer.getEnd());
int total = hits.getLength();


List resultRows = searchContainer.getResultRows();

String rootDir = PropsUtil.get(PropsUtil.DL_ROOT_DIR);
String versionRootDir = PropsUtil.get(PropsUtil.DL_VERSION_ROOT_DIR);

for (int i = 0; i < results.getLength(); i++) {
Document doc = results.doc(i);