I am developing a Portlet with Liferay (using liferay-ui in the JSP) and SpringMVC.
I have the following code in my JSP:
<liferay-ui:search-container delta="5" emptyResultsMessage="no books!">
<%
List<Book> bookList = (List<Book>)request.getAttribute("bookList");
List<Book> bookListView = ListUtil.subList(bookList, searchContainer.getStart(), searchContainer.getEnd());
%>
<liferay-ui:search-container-results results="<%= bookListView %>" total="${numberOfBooks}">
</liferay-ui:search-container-results>
...
I’d really like to get rid of the Java Code Block in the JSP and have the bookListView as model attribute just like numberOfBooks in the above code.
However, I can’t find a way to access searchContainer from the Spring Controller to get the start and end of the pagination…
Any ideas? Thx!
This might work for you:
Or else,
You can get the parameters from request:
delta=20&cur=2where
curis the current page which is requested anddeltais the total number of items on a page.With this you can calculate the start (0,20,40, …) and end (19,39,59, …) as does liferay’s
SearchContainerwith this method: