Search the FirstSpirit Knowledge Base
Dear All,
I want to sort the entity object for different language. So I have written a separate Comaparator calss in the Module, While calling the Comparator from the template I am getting exception (NullPointerException), but there is no stack trace for that. Is that possible to call the comparator in the module ??
Template Code Snippet:
$CMS_SET(comparator, class("de.espirit.util.comparator.CollatorComparator").instance())$
$CMS_SET(void,class("java.util.Collections").sort(entityList,comparator))$
CollatorComparator is the custom comparator Object
entityList - entity Object List
CollatorComparator.java
public static CollatorComparator getInstance (){
return new CollatorComparator();
}
@Override
public int compare(EntityImpl entity1, EntityImpl entity2)
{
return localeCollator.compare((String)entity1.get(Constants.table_column), (String) entity2
.get(Constants.table_column));
}
Dear Vasanth,
try the following:
<CMS_HEADER>
<CMS_FUNCTION name="contentSelect" resultname="yourContent">
<CMS_PARAM name="schema" value="yourSchema"/>
<QUERY entityType="yourEntityType">
</QUERY>
</CMS_FUNCTION>
</CMS_HEADER>
$CMS_SET(comparator,class("de.espirit.util.comparator.CollatorComparator").instance())$
$CMS_SET(arrayList,class("java.util.ArrayList").new(yourContent))$
$CMS_SET(void,class("java.util.Collections").sort(arrayList,comparator))$
Sincerely yours
Ismail
So I have written a separate Comaparator calss in the Module, While calling the Comparator from the template I am getting exception (NullPointerException), but there is no stack trace for that. Is that possible to call the comparator in the module ??
To get a trace you have to switch on debug mode:
$CMS_SET(#global.debugMode, true)$
Thank you Peter
Thank you Ismail. Its working fine ..