follow up to: sorted ftsearch results in XPages (with code!)
Julian Buss, January 26th, 2010 10:42:39
Tags:  Development 
This is a follow up to my previous post about sorted ftsearch results, and it is inspired by ideas Tommy Valand wrote about.

The problem with my previous approach was, that I could not cache the result. So while using a pager, or on re-sorting, all the expensive work (doing the ftsearch, getting all NotesViewEntries) was done over and over again. I could not cache the result, since the TreeMap contained Notes objects which are recyled after the page is delivered to the browser.

Now I created a "fake" NotesViewEntry object which only stored Java objects. So after doing the ftsearch, I create one fake NotesViewEntry for each real NotesViewEntry, and store that in the TreeMap. Then I get the sorted list of values (as Array) out of the TreeMap and store that into the viewScope.

On pagination I simply return that cached Array, and on re-sort I use that Array to re-sort the values. The ftsearch and looping over the NotesViewEntries is done only exactly once during the lifetime of the page.

I didn't implement the descending sort order yet, but that shouldn't be hard since the TreeMap.values() collection can be reversed by one single method call.

So, here is my current code as RTF download (sorry for that, but when I tried to put the code in this blog post, I reached the size limit of blog posts...): ynNotesView code.
The code contains lots of comments and should be easy to understand.

I'm happy about any comments how to improve that code further.
About this site
I am a Lotus Notes developer, consultant and one of the founders of YouAtNotes, a german software vendor specialized in Lotus Notes software for CRM, Workflow and Web solutions.
I write about IBM Lotus software and other stuff which I come across. Have a nice time here!

Search
RSS-Feeds
rssfeed.pngContent Feed
rssfeed.pngComment Feed
Recent posts
Recent comments
Links to YouAtNotes
Links to YouAtNotes (in german)
Archive
Impressum / Datenschutz
(german)