Foren

How to get a DLFileEntry from a velocity script?

thumbnail
Luis Rodríguez Fernández, geändert vor 14 Jahren.

How to get a DLFileEntry from a velocity script?

Junior Member Beiträge: 86 Beitrittsdatum: 26.06.09 Neueste Beiträge
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, geändert vor 14 Jahren.

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

Liferay Master Beiträge: 518 Beitrittsdatum: 20.07.05 Neueste Beiträge
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, geändert vor 14 Jahren.

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

Junior Member Beiträge: 28 Beitrittsdatum: 02.02.05 Neueste Beiträge
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, geändert vor 14 Jahren.

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

Junior Member Beiträge: 86 Beitrittsdatum: 26.06.09 Neueste Beiträge
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, geändert vor 12 Jahren.

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

New Member Beiträge: 11 Beitrittsdatum: 11.10.11 Neueste Beiträge
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