We need a list of documents (their titles shown) and those titles to link to the documents for downloading.
Refer below code,
We can use below code in velocity template,
Refer below code,
Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
DLFolder folder = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, dirName);
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
List<DLFileEntry> fileEntryService = null;
try {
fileEntryService = DLFileEntryLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(),folder.getFolderId(),-1, -1, null); //12345 is folderId
} catch (SystemException e) {
e.printStackTrace();
}
for(DLFileEntry fileEntryObj : fileEntryService){
System.out.println(fileEntryObj.getTitle());
}
We can use below code in velocity template,
#set($service = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
#set($fid = $getterUtil.getLong($folderId.getData()))
#set($files = $service.getFileEntries($gid, $fid))
#foreach($doc in $files)
#set($uet = $httpUtil.encodeURL($htmlUtil.unescape($doc.getTitle())))
<a href="/documents/$gid/$fid/$uet">$doc.getTitle()</a><br />
#end
No comments:
Post a Comment