0
votes

I have a tabbed panel containing different sections of a form. In one section, users are given the ability to add a child document to the currently open document. In a second section, they are given a listbox, where the options are dynamically generated (via @DbLookup) by looking at a view of all the child documents, filtered by the current document's ID. This functionality all works correctly, however, there is a problem with the dynamic listbox options.

When a user adds a new child document, then switches to the next tab, the listbox is not updated with this new document. If they save/re-edit the main document or refresh the page, it makes no different, the user must load another XPage before going back to the original in order for the listbox to update. I have tried to resolve this by doing full updates of the page, using session.evaluate and "NoCache" in the @DBLookup call, or calling database.getView("My view").refresh(), but without luck.

There is also a similar problem where I have a repeat control which uses a view of child documents (again filtered by main document ID) as a datasource. When a user adds a child document using a button, it partially refreshes the repeat - but doesn't show the new child document until the page is refreshed again (or you leave the page and return).

Is there something crucial I am missing with regards to the JSF lifecycle/the way that view data is cached?

1

1 Answers

3
votes

As first measure I would add another formula item to the listbox which simply returns the current time (@Now() should work). That way you can check if the listbox options are refreshed on the update in the first place.

If the options are refreshed fine it's indeed clear that the @DbLookup does some caching, although I'm not aware of any default caching logic.

At least for a test I would change the code to use a NotesView object instead of the @DbLookup, something like this:

var nview = database.getView("someview");
var nc = nview.getAllEntriesByKey(currentDocument.getDocument().getUniversalID(), true);
var a = [];
var ve = nc.getFirstEntry();
while (ve) {
  a.push(ve.getColumnValues().elementAt(0)); // value of first column
  ve = nc.getNextEntry(ve);
}
return a;

(I wrote the code from memory, there may be syntax errors).

Since the code only works with view entries it should be equally fast than the @DbLookup. And you could even do a nview.refresh() if needed.