我跟着this wiki併成功構建了自定義查詢。在Liferay搜索容器中顯示自定義查詢(連接表)的數據
它工作正常。我在表格之間使用了連接。
我的問題是如何使用liferay搜索容器在jsp上顯示它,因爲搜索容器中的className需要一個模型類。
編輯:
我已經試過到目前爲止是這樣的:
<%
getAttendanceData attName = new getAttendanceData();
List<Object[]> displayAttListName = AttendanceLocalServiceUtil.findAttendance();
ArrayList name = new ArrayList();
ArrayList title = new ArrayList();
ArrayList status = new ArrayList();
ArrayList remarks = new ArrayList();
for(Object[] att:displayAttListName) {
name.add(att[0]);
title.add(att[1]);
status.add(att[2]);
remarks.add(att[3]);
}
%>
<liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">
<liferay-ui:search-container-results
total="<%= displayAttListName.size() %>"
results="<%= ListUtil.subList(displayAttListName , searchContainer.getStart(), searchContainer.getEnd()) %>"
/>
<liferay-ui:search-container-row modelVar="search"
className="java.lang.Object">
<%
for(Object displayName:name) {
%>
<liferay-ui:search-container-column-text name='studName' value = '<%=String.valueOf(displayName)%>' href="">
</liferay-ui:search-container-column-text>
<%
}
%>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator/>
</liferay-ui:search-container>
上面我所顯示做各10名10次列。
我希望名稱出現在每一個新行上。我應該如何修改上面的代碼?
EDIT 2
考慮name
陣列前面定義我做了以下內容:
<liferay-ui:search-container-column-text name="employee name" href = "">
<%=name.getClass().getDeclaredFields().toString() %>
</liferay-ui:search-container-column-text>
通過上述,我得到的結果是這樣的:[Ljava.lang.reflect.Field;@195f1af
每行。
你從'選擇'中得到什麼?通常,在「服務」構建器的「自定義查詢」中,您將獲得一個類/實體的實例數組。表 – yannicuLar
@ yannicuLar: 我從兩個表中獲取數據。我加入了: select studat(stud.studFname,'',stud.studLname)as studName,stud.studTitle,attendance.attRemarks,attendance.attStatus from student stud left outer join attendance on stud.studId =考勤,考勤和考勤。attDate ='2013-05-20'; 我採取了內部連接。 如何在liferay搜索容器中顯示上述查詢的結果? 像我說我不知道該怎麼把className –
@ yannicuLar:: 對不起,我已經採取了左外連接..不內連接..就像我在以前的評論中說的 –