liferay 提供<liferay-ui:search-container>標籤 方便實現查詢翻頁功能:html
<liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found"> <liferay-ui:search-container-results results="<%= UserLocalServiceUtil.search( company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams, searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator()); %>" total="<%= UserLocalServiceUtil.searchCount( company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams); %>" /> <liferay-ui:search-container-row className="com.liferay.portal.model.User" keyProperty="userId" modelVar="user" > <liferay-ui:search-container-column-text name="name" value="<%= user.getFullName() %>" /> <liferay-ui:search-container-column-text name="first-name" property="firstName" /> </liferay-ui:search-container-row> <liferay-ui:search-iterator /> </liferay-ui:search-container> <liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found">
This is the container. It performs a lot of set up work behind the scenes like instantiating the searchContainer object.api
<liferay-ui:search-container-results results="<%= UserLocalServiceUtil.search( company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams, searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator()); %>" total="<%= UserLocalServiceUtil.searchCount( company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams); %>" />
<liferay-ui:search-container-row className="com.liferay.portal.model.User" keyProperty="userId" modelVar="user">
<liferay-ui:search-container-column-text name="name" value="<%= user.getFullName() %>" />
<liferay-ui:search-container-column-text name="first-name" property="firstName" />
Important to note here; regardless of attribute capitalisation in your service.XML, the property value must always start lower case. After that it seems to follow what you defined.less
<liferay-ui:search-iterator />
Hopefully, this gives you a jump start on how to use Liferay's SearchContainer in your own portlets.ide