Foros de discusión

Simple list of files inside a folder - how to?

Anne Hautakangas, modificado hace 9 años.

Simple list of files inside a folder - how to?

New Member Mensajes: 3 Fecha de incorporación: 22/08/14 Mensajes recientes
I'm quite new to Liferay and I'm trying to find a way to list all files inside a certain folder. I tried using the Documents and Media display, but the list shows too much information to my liking. I would only need a list of documents (their titles shown) and those titles to link to the documents for downloading.

Could you advice what would be the easiest way to accomplish this? I'm using Liferay 6.2.
thumbnail
Mayur Patel, modificado hace 9 años.

RE: Simple list of files inside a folder - how to?

Expert Mensajes: 358 Fecha de incorporación: 17/11/10 Mensajes recientes
Hi Anne,

Please try below code,

  ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
		
		List<dlfileentry> fileEntryService = null;
		try {
			fileEntryService = DLFileEntryLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(),12345,-1, -1, null); //12345 is folderId
		} catch (SystemException e) {
			e.printStackTrace();
		}
		
		for(DLFileEntry fileEntryObj : fileEntryService){
			System.out.println(fileEntryObj.getTitle());
		}</dlfileentry>


To fetch folderId from folderName, Refer this link

Thanks.
Anne Hautakangas, modificado hace 9 años.

RE: Simple list of files inside a folder - how to?

New Member Mensajes: 3 Fecha de incorporación: 22/08/14 Mensajes recientes
Thanks - but I don't where I should use that code... emoticon

I guess I need to study this a bit more.