Wednesday, 23 February 2011

Improved caching for Xpages DbLookup and DbColumn

A while back I blogged about a failing repeat control in Xpages when passing it a single value returned from a @DbLookup or @DbColumn. In the comments to this entry it was already mentioned by some that it needs an array as input.
The other week I received a reply from IBM on my PMR (87011,211,788) stating exactly that, "The repeat control works as designed, it needs an array as input.".
From the earlier comments on that blogpost I had already started using the suggested solution from the xpages wiki by Julian Buss.
But like in the Notes client not every situation calls for cached results, so I amended this code to allow for cache or not. And instead of requestScope I used sessionScope as I want the cache to last until the session is ended (browser closed/session times out).
If you want to use it, put the code below in a server side JavaScript library and you are ready to use it.

The code has been moved and can be found here:

The code has been moved and can be found here:


david leedy said...

cool. Thanks for sharing!!

Paul S Withers said...

While revisiting an old presentation with a screenshot from my first application I saw I had wrapped an @DbLookup inside @List. That was way back in May 2009 when I was an XPages newbie though, so not sure if it's good or bad practice.