留言板
Set a variable not working
Hi,
I'm trying to set a variable with the value of a method. But it doesn't work:
But if I use this code, it print the correct value:
Why I can't set a variable with the value?
Regards,
Andrés
I'm trying to set a variable with the value of a method. But it doesn't work:
#set ($assetLinkLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetLinkLocalService"))
#set ($assetlinks = $assetLinkLocalService.getDirectLinks( $ae.getEntryId() ))
#set ($siz = $assetlinks.size())
But if I use this code, it print the correct value:
#set ($assetLinkLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetLinkLocalService"))
#set ($assetlinks = $assetLinkLocalService.getDirectLinks( $ae.getEntryId() ))
$assetlinks.size()
Why I can't set a variable with the value?
Regards,
Andrés
If the second code works than the first should as well. If you do want to see the print out you would have to print out the $siz variable. It would look like this:
What is the value of the $ae variable, so I can test it?
#set ($assetLinkLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetLinkLocalService"))
#set ($assetlinks = $assetLinkLocalService.getDirectLinks( $ae.getEntryId() ))
#set ($siz = $assetlinks.size())
$siz
What is the value of the $ae variable, so I can test it?
The problem is that I get this error:
java.lang.NullPointerException
When I try to set a variable with the size value. The first code doesn't work.
Regards,
Andrés
java.lang.NullPointerException
When I try to set a variable with the size value. The first code doesn't work.
Regards,
Andrés