[xwiki-users] ordering attachements not working`
Sometime ago I was given this code to add to attachmentsinline.vm #set($attachmentsMap = $util.hashMap) #foreach($a in $attachments) #set($discard = $attachmentsMap.put($a.date, $a)) #end #set($dates = $util.arrayList) #foreach($date in $attachmentsMap.keySet()) #set($discard = $dates.add($date)) #end #set($dates = $util.sort($dates)) #set($dates = $util.reverseList($dates)) #set($attachments = $util.arrayList) #foreach($date in $dates) #set($discard = $attachments.add($attachmentsMap.get($date))) #end this works fine, putting the attachments in order on my local server However, my client (running XWiki Enterprise 1.5.1.12494) reports that it doesn't show all the attachments. He has one page with about 10 attachments, only 5 of which show. If he takes the code out all the attachments are there, but not in date order which he wants. can anyone please help.
Edward Laptop wrote:
Sometime ago I was given this code to add to attachmentsinline.vm
#set($attachmentsMap = $util.hashMap) #foreach($a in $attachments) #set($discard = $attachmentsMap.put($a.date, $a)) #end #set($dates = $util.arrayList) #foreach($date in $attachmentsMap.keySet()) #set($discard = $dates.add($date)) #end #set($dates = $util.sort($dates)) #set($dates = $util.reverseList($dates)) #set($attachments = $util.arrayList) #foreach($date in $dates) #set($discard = $attachments.add($attachmentsMap.get($date))) #end
this works fine, putting the attachments in order on my local server
However, my client (running XWiki Enterprise 1.5.1.12494) reports that it doesn't show all the attachments. He has one page with about 10 attachments, only 5 of which show. If he takes the code out all the attachments are there, but not in date order which he wants.
can anyone please help.
I guess some attachments have the same date, thus they overlap in the hashmap. Try this: #set($attachmentsMap = $util.hashMap) #foreach($a in $attachments) #if(!$attachmentsMap.containsKey($a.date)) #set($discard = $attachmentsMap.put($a.date, $util.arrayList)) #end #set($discard = $attachmentsMap.get($a.date).add($a)) #end #set($dates = $util.arrayList) #foreach($date in $attachmentsMap.keySet()) #set($discard = $dates.add($date)) #end #set($dates = $util.sort($dates)) #set($dates = $util.reverseList($dates)) #set($attachments = $util.arrayList) #foreach($date in $dates) #set($discard = $attachments.addAll($attachmentsMap.get($date))) #end -- Sergiu Dumitriu http://purl.org/net/sergiu/
Thanks for the new code Sergiu - client reports it working fine I will update the FAQ with the new version -----Original Message----- From: [email protected] [mailto:[email protected]]On Behalf Of Edward Laptop Sent: 05 November 2008 11:03 To: XWiki Users Subject: [xwiki-users] ordering attachements not working` Sometime ago I was given this code to add to attachmentsinline.vm #set($attachmentsMap = $util.hashMap) #foreach($a in $attachments) #set($discard = $attachmentsMap.put($a.date, $a)) #end #set($dates = $util.arrayList) #foreach($date in $attachmentsMap.keySet()) #set($discard = $dates.add($date)) #end #set($dates = $util.sort($dates)) #set($dates = $util.reverseList($dates)) #set($attachments = $util.arrayList) #foreach($date in $dates) #set($discard = $attachments.add($attachmentsMap.get($date))) #end this works fine, putting the attachments in order on my local server However, my client (running XWiki Enterprise 1.5.1.12494) reports that it doesn't show all the attachments. He has one page with about 10 attachments, only 5 of which show. If he takes the code out all the attachments are there, but not in date order which he wants. can anyone please help. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
Edward Laptop -
Sergiu Dumitriu