Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: OrderByComparator in Velcoity template
Hi,
I'm trying to use this method #set ($messages = $MBLocalServiceMessage.getGroupMessages($groupId, 0, -1,-1, MessageCreateDateComparator obc)) but I don't know how to use the OrderByComparator method. Thanks
JAOUAD MOUAOU:Hi,
I'm trying to use this method #set ($messages = $MBLocalServiceMessage.getGroupMessages($groupId, 0, -1,-1, MessageCreateDateComparator obc)) but I don't know how to use the OrderByComparator method. Thanks
Have you already using reflection to instantiate the
OrderByComparator? It's something that Ray documented in
an old blog post, Tricks
of Velocity class loading.
this is what I have done so far but it dosen't seem to work, I want to get messages from Newest to oldests.
#set ($obcClass =
$portal.getClass().forName("com.liferay.portlet.messageboards.util.comparator.MessageCreateDateComparator"))
#set ($booleanType =
$portal.getClass().forName('java.lang.Boolean'))
#set
($obcConstructor =
$obcClass.getConstructor($booleanType.getField('TYPE').staticValue))
#set ($obc = $obcConstructor.newInstance(false))
#set ($messages =
$MBLocalServiceMessage.getGroupMessages($groupId, 0, -1, -1, $obc))
Thank you very much. I've solved the problem by overriding the below parameter. I'm using Liferay 6.2 and it turns out the classes are restricted by default in velocity.
velocity.engine.restricted.classes=