« Back to home

Domino XPages namePicker vs Directory Assistance

A common need in Domino applications is a way to add one or more users to a list using their Domino IDs, for example to add additional allowed editors to a document.

In the Notes client, this is pretty easy — you select “Use Address dialog for choices” in a drop-down, and optionally check the two boxes to turn on autocomplete. Done.

In XPages, it’s nowhere near that simple.

The XPages Extension Library — which is now a standard part of Domino — provides a Name Picker componebnt, xe:namePicker. However, if you drop it on a page you’ll discover that it has no user-friendly properties editing box, just the long list of All Properties.

If you venture into the raw property list, you’ll find that there’s a dataProvider property you need to supply to tell the control how to fetch name and address book values. One of those is xe:dominoNABNamePicker, which looks hopeful, so you pick it. It doesn’t work. You try setting addressBookSel="all", and still it doesn’t work.

What’s wrong? Maybe, like me, you have a server that’s set up to use Directory Assistance. In my case, the server is configured with an LDAP server as a secondary directory, and a custom address book design as a tertiary source. In formula language and LotusScript everything works as expected — @NameLookup finds people exactly as if they were in names.nsf, and so do the corresponding LotusScript and Java classes.

Unfortunately, inspecting the source code for dominoNABNamePicker reveals that it assumes all the name and address books are Domino databases and reads from their views directly. There’s no name picker that uses the standard directory lookup mechanisms. As far as I could tell, nobody had published an example of one either.

So, here’s my attempt

The “glue” is the readEntries method. XPages passes in various options, but the ones relevant to the Name Picker are the count of how many results to return, and the start key.

The heavy lifting is done by the dirLookup method. The code is basically a straight Java version of the corresponding LotusScript code, but assembling the results into appropriate picker entry objects.

Once you’ve got the Java file added to your database and compiled, using it is simple — just choose beanNamePicker as the source for the Extension Library name picker, and specify DirectoryNamePicker as the dataBean. Note that it’s not a bean in the JSF sense, so you don’t need to set up anything in faces-config.xml.

Hopefully at some point something similar will make it into the official ExtLib releases, but for now I have something that works adequately.