Hi All, I am using velocity 1.5 sortTool to sort the properties of list. I am sorting two date, createdAt and updatedAt both property of dto are java.util.Date type. I am trying to sort on updatedAt first and if updatedAt is null then on createdAt. Its working fine if there is some value in updatedAt, but its not working if updatedAt has null value. Please help me out of this problem. code sample is attached with this mail.
Thanks & Regards, Ranjeet
<tool> <key>sorter</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.SortTool</class> </tool> velocity Code ============ #foreach($obj in $sorter.sort(${campaign.notes}, ["updatedAt:desc", "createdAt:desc"])) $obj.id, $obj.shortText , crreatedAt : $obj.createdAt , updatedAt : $obj.updatedAt <br /> #end DTO implements Comparable<Note> with method private Date createdAt; private Date updatedAt; // and their setter/getter method. public int compareTo(Note other) { //Note other = (Note)o; int returnValue = 0; if (this.getUpdatedAt() != null && other.getUpdatedAt() != null) { returnValue = this.getUpdatedAt().compareTo(other.getUpdatedAt()); if (returnValue == 0){ returnValue = this.getCreatedAt().compareTo(other.getCreatedAt()); } } else { returnValue = this.getCreatedAt().compareTo(other.getCreatedAt()); } return returnValue; }*
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org