留言板

How to get a DLFileEntry from a velocity script?

thumbnail
Luis Rodríguez Fernández,修改在14 年前。

How to get a DLFileEntry from a velocity script?

Junior Member 帖子: 86 加入日期: 09-6-26 最近的帖子
Hi everyone!

We get the typical "News" section in our portal. The detail of each one is made by date, title, content and one or more documents from the document library.

The problem is that we can't get each of theses documents. We have tried with the next code:

#set($dlFileEntryUtil = $serviceLocator.findExceptionSafeService('com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryUtil'))

#set($fileEntry = $dlFileEntry.getFileEntryByUuidAndGroupId($fileEntryUuid,$fileEntryGroupId))

It seems that we can get the service but their methods don't work!

Any idea?

Thanks,

Luis

--
So far the Universe is winning

Rick Cook
--
thumbnail
Alexander Chow,修改在14 年前。

RE: How to get a DLFileEntry from a velocity script?

Liferay Master 帖子: 518 加入日期: 05-7-20 最近的帖子
Luis Rodríguez Fernández:

#set($dlFileEntryUtil = $serviceLocator.findExceptionSafeService('com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryUtil'))

#set($fileEntry = $dlFileEntry.getFileEntryByUuidAndGroupId($fileEntryUuid,$fileEntryGroupId))


It looks like you have a typo. Try:

#set($fileEntry = $dlFileEntryUtil.getFileEntryByUuidAndGroupId($fileEntryUuid,$fileEntryGroupId))
thumbnail
Thomas Ballerstedt,修改在14 年前。

RE: How to get a DLFileEntry from a velocity script?

Junior Member 帖子: 28 加入日期: 05-2-2 最近的帖子
Hi,

please try as follows:


#set($dlFileEntryUtil = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set ($longGroupId = $getterUtil.getLong($groupId))
#set($fileEntry = $dlFileEntryUtil.getFileEntryByUuidAndGroupId($uuid,$longGroupId))


Above works for me. Using .findExceptionSafeService instead, doesn't work with my environment either. I don't know why.
Using $getterUtil.getLong($groupId)) for long Types maybe important too.

I'm running liferay 5.2.3 at rev. 33675 from svn.branch

Good luck.

Cheers,
Thomas
thumbnail
Luis Rodríguez Fernández,修改在14 年前。

RE: How to get a DLFileEntry from a velocity script?

Junior Member 帖子: 86 加入日期: 09-6-26 最近的帖子
Thanks!!!

Both were right. I had a typo error and with 5.2.3 I can't use serviceLocator.findSafeExceptionService.

Regards,

Luis
thumbnail
Arya Nugroho,修改在12 年前。

RE: How to get a DLFileEntry from a velocity script?

New Member 帖子: 11 加入日期: 11-10-11 最近的帖子
hi, what if I want to get values ​​from fields other web content created by xml schema, where the fields are taken only web content in a particular tag with a velocity template script on my web content?


thanks a lot,
regards