这是我的Liferay搜索容器代码:
MVC:BigInteger leaveTotalCount;
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
PortletURL iteratorURL = PortletURLFactoryUtil.create(request, themeDisplay.getPortletDisplay().getId(),
themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
SearchContainer<LeaveDetailsWrapper> searchContainer = null;
searchContainer = new SearchContainer<>(request, null, null, SearchContainer.DEFAULT_CUR_PARAM,
SearchContainer.DEFAULT_DELTA, iteratorURL, null, LmsLeaveDashboardConstant.BLANK_STRING);
List<LeaveDetailsWrapper> leaveDetails;
try {
searchContainer.setDeltaConfigurable(true);
leaveDetails = leaveLocalService.getLeaveDetails(null, null, null, null,
LmsLeaveDashboardUtils.getEmpCode(request), searchContainer.getStart(), searchContainer.getEnd());
log.info(leaveDetails);
leaveTotalCount = leaveLocalService.getLeaveDetailsCount(null, null, null, null,
LmsLeaveDashboardUtils.getEmpCode(request), -1, -1);
searchContainer.setEmptyResultsMessage("No Data Found..!");
searchContainer.setTotal(leaveTotalCount.intValue());
searchContainer.setIteratorURL(iteratorURL);
searchContainer.setResults(leaveDetails);
} catch (Exception e) {
log.error("ERROR:IntrahrmsLmsLeaveDashboardWebPortlet leaveSearchContianer" + e);
}
return searchContainer;
jsp:
<liferay-ui:search-container searchContainer="${leaveInfoContainer}" iteratorURL="${iteratorURL}">
<liferay-ui:search-container-results
results="${leaveInfoContainer.getResults()}" />
<liferay-ui:search-container-row
className="com.intrahrms.lms.service.leavecustom.model.LeaveDetailsWrapper"
modelVar="LeaveDetails">
<liferay-ui:search-container-column-text
value="${LeaveDetails.leaveTypeName} Leave " name="Leave Type" />
<liferay-ui:search-container-column-text name="From Date">
<fmt:formatDate pattern="dd/MM/yyyy"
value="${LeaveDetails.fromDate}" type="date" />
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text name="To Date">
<fmt:formatDate pattern="dd/MM/yyyy" value="${LeaveDetails.toDate}"
type="date" />
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text
value="${LeaveDetails.totalDays}" name="Total Leave Days" />
<liferay-ui:search-container-column-text name="Applied Date">
<fmt:formatDate pattern="dd/MM/yyyy"
value="${LeaveDetails.appliedDate}" type="date" />
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text
value="${LeaveDetails.leaveStatus} " name="Status" />
<liferay-ui:search-container-column-text
value="${LeaveDetails.projectManagerId}" name="Reporting Manager" />
<liferay-ui:search-container-column-jsp path="/action.jsp"
align="center" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator markupView="lexicon" />
</liferay-ui:search-container>
问题是当我更改分页或更改增量时,它会给我整个记录而不是过滤记录。
答案 0 :(得分:0)
您的搜索容器似乎在做正确的事情,如下:
leaveDetails = leaveLocalService.getLeaveDetails(null, null, null, null,
LmsLeaveDashboardUtils.getEmpCode(request), searchContainer.getStart(), searchContainer.getEnd());
考虑一下:您刚刚创建了实例,您期望开始和结束时是什么?
在创建容器时,您告诉它应该使用的参数,但是没有在JSP上设置它们,例如:
<liferay-ui:search-container emptyResultsMessage="there-are-no-file-entries" iteratorURL="${filesRenderUrl}" delta="${files_searchDelta}" total="${files_searchTotal}" curParam="files" deltaParam="files">
最下面一行,如果您想用这样的java方法控制搜索容器,则需要采取相应的措施来设置结果:
private static int getStart( int current, int delta ) {
return ( current - 1 ) * delta;
}
private static int getEnd( int first, int delta ) {
return first + delta;
}