我必须根据expando值显示DLFileEntry记录。我已经按照我认为足够清楚的链接https://www.liferay.com/community/wiki/-/wiki/Main/Search+for+objects+by+custom+attributes了。
当我在这里实施同样的事情时...我得到'没有记录可用'..
我从循环中获取的主键值存在于DLFileEntryMetadata中,但不存在于DLFileEntry表中。因此,显示的默认消息是没有可用的记录。
<liferay-ui:search-container delta="5" emptyResultsMessage=
"no-records-available- for-employee" deltaConfigurable="true" >
<liferay-ui:search-container-results>
<%
long classNameId = ClassNameLocalServiceUtil.getClassNameId(DLFileEntry.class);
long companyId = PortalUtil.getDefaultCompanyId();
List<ExpandoValue> values = ExpandoValueLocalServiceUtil.getColumnValues(companyId,
classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME,
"employeeId",String.valueOf(employeeId), -1, -1);
out.println(values.isEmpty());
List<DLFileEntry> empFiles = new ArrayList<DLFileEntry>();
DLFileEntry fileEntry;
for (int i = 0; i < values.size(); i++) {
long fileId = values.get(i).getClassPK();
try{
out.println(userId);
fileEntry = DLAppLocalServiceUtil.getFileEntry(fileId);
empFiles.add(fileEntry);
}catch(Exception e ){
}
}
searchContainer.setResults(empFiles);
total = results.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>
<liferay-ui:search-container-row className="com.liferay.portlet.documentlibrary.model.DLFileEntry" modelVar="fileEntry" rowVar="curRow"
escapedModel="<%=true %>">
<liferay-ui:search-container-column-text orderable="true" name="Name"
property="name" />
<liferay-ui:search-container-column-text orderable="true" name="Extension"
property="extension"/>
<liferay-ui:search-container-column-text orderable="true" name="Mime Type"
property="mimeType"/>
<liferay-ui:search-container-column-text orderable="true" name="Title"
property="title"/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator/>
答案 0 :(得分:2)
你排队的身份证明:
long fileId = values.get(i).getClassPK();
不是文件ID,而是文件版本ID。尝试替换你的行:
fileEntry = DLAppLocalServiceUtil.getFileEntry(fileId);
以下一个:
fileEntry = DLAppLocalServiceUtil.getFileVersion(fileId).getFileEntry();
br,Pawel
答案 1 :(得分:1)
由于无法将FileEntry强制转换为DLFileEntry,因此最好从此行获取fileEntryId
long fileEntryId2 = DLAppLocalServiceUtil.getFileVersion(fileId).getFileEntryId();
然后
fileEntry = DLFileEntryLocalServiceUtil.getDLFileEntry(fileEntryId2);