Forums de discussion
Set a variable not working
andres digiovanni, modifié il y a 11 années.
Set a variable not working
New Member Publications: 14 Date d'inscription: 18/09/12 Publications récentes
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
Ryan Schuhler, modifié il y a 11 années.
RE: Set a variable not working
Junior Member Publications: 77 Date d'inscription: 06/07/12 Publications récentes
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?
andres digiovanni, modifié il y a 11 années.
RE: Set a variable not working
New Member Publications: 14 Date d'inscription: 18/09/12 Publications récentes
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
Ryan Schuhler, modifié il y a 11 années.
RE: Set a variable not working
Junior Member Publications: 77 Date d'inscription: 06/07/12 Publications récentes
It is definitely possible to set the variable with the value of the method, you already did it twice with .findService() and .getDirectLinks(). Can you attach your code so I can see where the disconnect is or why its giving you the null pointer exception?