Forums de discussion

Services in Journal Velocity templates

Alessandro Cosenza, modifié il y a 14 années.

Services in Journal Velocity templates

Junior Member Publications: 84 Date d'inscription: 19/11/09 Publications récentes
Hello,
in my template I write

set ($articleService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))


then
#set ($ja = $articleService.getArticle($groupId,$reserved-article-id))
#set ($artId = $ja.getArticleId())


but it seems i can't get the variable working.

also I put in portal-ext.properties

journal.template.velocity.restricted.variables=


but it doesn't work.

Any help?
Thanks in advance.
Daphné Bellemin, modifié il y a 14 années.

RE: Services in Journal Velocity templates

New Member Publications: 6 Date d'inscription: 03/03/08 Publications récentes
Hello,

Does $articleService display something?

Have you tried using
com.liferay.portlet.journal.service.JournalArticleService instead of local service?

Daphné
Alessandro Cosenza, modifié il y a 14 années.

RE: Services in Journal Velocity templates

Junior Member Publications: 84 Date d'inscription: 19/11/09 Publications récentes
OK now it seems it works.
The main problem was that I used incorrect parameters types.

$articleService displays the instance of the object

com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl@d7be04

I did

$articleService.getArticle($groupId,$reserved-article-id.getData())


the correct one is

$articleService.getArticle($getterUtil.getLong($groupId),$reserved-article-id.getData())


$groupId is String and needs to be converted to long because getArticle takes long.

Thank for your answer.