Fórum

Refresh documents list in a custom velocity template

thumbnail
Mario R, modificado 9 Anos atrás.

Refresh documents list in a custom velocity template

Junior Member Postagens: 55 Data de Entrada: 06/06/13 Postagens Recentes
Hello everyone!!
I'm doing development with liferay 6.1.2 ga3.
I want to list files uploaded into specific folder in the documents and media library.
The document list should be displayed with a custom style. (In a simple way, withouth documents and media viewer)
The applied solution is:
1. Create a structure with a field called folderName
2. Create a template for that structure, and using the service locator, finds all documents in a specific folder.
3. Create a web content using the structure and template created

The problem is when new documents are uploaded to the folder, they are not automatically listed in the web content.
Only refresh if the web content, estructure or template are updated; or after approximately 15 minutes without interacting with the browser.
The following snippet illustrates the code used

  ## instance of DLFileEntry service
 #set($fileService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
 
 ## get group id
 #set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
 
 ##search documents by folderId
 #set($fid = $getterUtil.getLong($folder.folderId))
 #set($files = $fileService.getFileEntries($gid, $fid, -1, -1, null))

 #foreach($doc in $files)
     <div class="base-margin">
       <h3>$doc.getTitle()</h3>
       <p>$doc.getDescription()</p>
     </div>
 #end



Thanks for your help....

Atte:
Mario
thumbnail
Andew Jardine, modificado 9 Anos atrás.

RE: Refresh documents list in a custom velocity template

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hey Mario,

That sounds like a content cache issue to me -- especially if it is always at the 15 minute mark. You could try customizing the cache interval for the content cache to see if a lower value yields your results quicker, but that probably isn't what you want for a long term solution you want. If it is the cache, I can think of an alternative you could try. Maybe create a Struts Action hook. Execute the originalStrutsAction from your hook -- which will do the normal add document functionality, but when that return force a flush of the cache.

Looking at the struts-config.xml I think you might be looking at hooking the EditFileEntryAction.class from the package com.liferay.portlet.documentlibrary.action if you want to try that.
thumbnail
Mario R, modificado 9 Anos atrás.

RE: Refresh documents list in a custom velocity template

Junior Member Postagens: 55 Data de Entrada: 06/06/13 Postagens Recentes
Hi, thanks for your reply!
I'm testing with your suggestion!

Atte;
Mario
thumbnail
Mario R, modificado 9 Anos atrás.

RE: Refresh documents list in a custom velocity template

Junior Member Postagens: 55 Data de Entrada: 06/06/13 Postagens Recentes
Hello, i solve it!
The correct solution is to uncheck the cacheable box in the velocity template. It is necesary if you are using a liferay api framework for displaying dynamic content.

Thanks!
thumbnail
Andew Jardine, modificado 9 Anos atrás.

RE: Refresh documents list in a custom velocity template

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
He didn't make any reference to the asset publisher at all -- he even posted code that clearly shows he is creating a velocity template where he is trying to use this logic. What value does your post add? it doesn't even address his question. The title for the post even references a "customs velocity template" ... no mention of asset publisher :|