1

In my Liferay 6.2 EE Velocity Webcontent template i declared the themeDisplay object as follows:

#set ($themeDisplay = $request.theme-display)

I also adapted my portal-ext.properties:

velocity.engine.restricted.classes=
velocity.engine.restricted.variables=

Now i want to invoke the following method call:

#set ($articleId = $cross_selling.getData())
      #set ($result = $JournalArticleLocalService.getArticleDisplay($groupId, $articleId, $viewMode, $themeDisplay.getLanguageId(), $themeDisplay))
            $result

but the unexpected output is the following:

$result

What is the best way within Velocity to make a method call to $JournalArticleLocalService ?

Thanks

HelmutSteiner
  • 99
  • 2
  • 11

1 Answers1

2

If you have not set $JournalArticleLocalService you should do that first as follows. You can then use all the methods available to JournalArticleLocalService.

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

You should also do a null check for the article ID before attempting to use it.

Lifehack
  • 1,981
  • 15
  • 12
  • Sorry, i forgot to provide you the whole code snippet: – HelmutSteiner Oct 25 '16 at 07:02
  • `#set ($JournalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))` - I already did this – HelmutSteiner Oct 25 '16 at 07:04
  • Your code seems to be fine as per you previous comments and questions. Then there is only one possibility that your webcontent is of different format which getArticleDisplay() method doesn't support. Check this link- https://docs.liferay.com/portal/6.2/javadocs/com/liferay/portlet/journal/service/JournalArticleLocalService.html#getArticleDisplay(long,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20com.liferay.portal.theme.ThemeDisplay) – Neeraj Gautam Oct 25 '16 at 12:07
  • @NeerajGautam Oh, i see. Will try it with all described method calls. One should work... – HelmutSteiner Oct 25 '16 at 14:25