掲示板
Get new instance in Volecity template
8年前 に jason zhao によって更新されました。
Get new instance in Volecity template
New Member 投稿: 7 参加年月日: 14/08/05 最新の投稿
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.
8年前 に James Falkner によって更新されました。
RE: Get new instance in Volecity template
Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
See this thread. The Collections class cannot be instantiated (no public constructors) and consists only of static utility methods.
8年前 に jason zhao によって更新されました。
RE: Get new instance in Volecity template
New Member 投稿: 7 参加年月日: 14/08/05 最新の投稿
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?
8年前 に James Falkner によって更新されました。
RE: Get new instance in Volecity template
Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
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.
8年前 に jason zhao によって更新されました。
RE: Get new instance in Volecity template
New Member 投稿: 7 参加年月日: 14/08/05 最新の投稿
Thx for answering, I tried this exact code in my Liferay 6.2 EE, didn't work...Maybe there's a patch or sth?
8年前 に James Falkner によって更新されました。
RE: Get new instance in Volecity template
Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
Which version of 6.2 EE, and which version of Java are you using? I'll get the exact same setup and try it.