Foros de discusión
Get new instance in Volecity template
jason zhao, modificado hace 8 años.
Get new instance in Volecity template
New Member Mensajes: 7 Fecha de incorporación: 5/08/14 Mensajes recientes
I've been trying to get a instance of Collections in vm template for Gallery display template.
I write
this in my template.
I think it should work, but I got $coll.shuffle($entries) this displayed on my actual page.
I'm not sure what's wrong, help me plz.
I write
#set($coll = $portal.getClass().forName("java.util.Collections").newInstance())
$coll.shuffle($entries)
this in my template.
I think it should work, but I got $coll.shuffle($entries) this displayed on my actual page.
I'm not sure what's wrong, help me plz.
James Falkner, modificado hace 8 años.
RE: Get new instance in Volecity template
Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes
See this thread. The Collections class cannot be instantiated (no public constructors) and consists only of static utility methods.
jason zhao, modificado hace 8 años.
RE: Get new instance in Volecity template
New Member Mensajes: 7 Fecha de incorporación: 5/08/14 Mensajes recientes
Thx for replying. I tried this before, there's no error but the list didn't seem to be shuffled at all no matter how many times I refresh the page or clean the VM and database cache.
Is there someting wrong with the way I code?
#set ($coll = $portal.getClass().forName('java.util.Collections'))
#set ($V = $coll.shuffle($entries))
#foreach ($curFileEntry in $entries)
Is there someting wrong with the way I code?
James Falkner, modificado hace 8 años.
RE: Get new instance in Volecity template
Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes
This worked for me in 6.2:
Every time I refresh the page, the order of article titles is changed randomly.
#set ($coll = $portal.getClass().forName('java.util.Collections'))
#if (!$entries.isEmpty())
#set ($V = $coll.shuffle($entries))
<ul>
#foreach ($curEntry in $entries)
<li>$curEntry.getTitle($locale)</li>
#end
</ul>
#end
Every time I refresh the page, the order of article titles is changed randomly.
jason zhao, modificado hace 8 años.
RE: Get new instance in Volecity template
New Member Mensajes: 7 Fecha de incorporación: 5/08/14 Mensajes recientes
Thx for answering, I tried this exact code in my Liferay 6.2 EE, didn't work...Maybe there's a patch or sth?
James Falkner, modificado hace 8 años.
RE: Get new instance in Volecity template
Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes
Which version of 6.2 EE, and which version of Java are you using? I'll get the exact same setup and try it.