Fórumok
Set a variable not working
andres digiovanni, módosítva 11 év-val korábban
Set a variable not working
New Member Bejegyzések: 14 Csatlakozás dátuma: 2012.09.18. Legújabb bejegyzések
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, módosítva 11 év-val korábban
RE: Set a variable not working
Junior Member Bejegyzések: 77 Csatlakozás dátuma: 2012.07.06. Legújabb bejegyzések
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, módosítva 11 év-val korábban
RE: Set a variable not working
New Member Bejegyzések: 14 Csatlakozás dátuma: 2012.09.18. Legújabb bejegyzések
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, módosítva 11 év-val korábban
RE: Set a variable not working
Junior Member Bejegyzések: 77 Csatlakozás dátuma: 2012.07.06. Legújabb bejegyzések
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?