Extension Library Name Picker gets local Names.nsf even though DB is on server

1k Views Asked by At

I have a Name Picker on an XPage with a dataProvider dominoNABNamePicker with the addressBookSel = all-public and people and groups = true. With the database on a Domino server using the Notes Client it displays my local Names.nsf. If I open the DB in a brouse it selects the correct names.nsf from the server. Can't figure out if this is the result of settings in my client, the server or XPages. Does the same thing on two different PC's. I would think that the all-public would force it to open only public NABs but it does not appear so.

3

There are 3 best solutions below

2
On

After a fair bit of frustration I have this working for the Notes Client and the Web Client. Perhaps this is obvious to most of you, but it sure wasn't to me. First on the Name Picker I created a namePickerAggregator. Then I added a dominoNABNamePicker in the addressBookDb I put the following SSJS:

var server:String = @Name("[CN]",session.getCurrentDatabase().getServer());
var allNABs:Array = session.getAddressBooks().iterator();
var pubNABs = new Array;
var privNABs = new Array;
while (allNABs.hasNext()) {
    var db:NotesDatabase = allNABs.next();
    if (db.isPublicAddressBook()){
        pubNABs.push(db.getFileName())
    } else {
        privNABs.push(db.getFileName())
    }
    db.recycle()
}


   if (pubNABs[0] == ""){
    return privNames[0];
    break;
} else {
    return server + "!!" + pubNABs[0];
    break
}

I then added a second dominoNABNamePicker with the same block of code except the return is

if (pubNABs[1] != "") {
    return server + "!!" + pubNABs[1];
    break;
} else {
    return "";
}

This code works for both the Notes Client and the Web client so I'm now a happy camper, unless I find a gotcha somewhere.

0
On

I asked the same question myself.

The answer, in the control add addressBookDb="SERVER!!names.nsf"

From here.

Can I have the extlib name picker running in xPINC lookup the directory on the server?

0
On

Here is what I eventually did. I set a limit on the maximum number of address books (not great but it works) of 4 you can create as many as you want. So I created a couple of sessionScope variable that I created in the after Page Loads event on the XPage. I used this formula.

var allNABs:Array = session.getAddressBooks().iterator();
var pubNABs = new Array;
var privNABs = new Array;
while (allNABs.hasNext()) {
    var db:NotesDatabase = allNABs.next();
    if (db.isPublicAddressBook()){
        pubNABs.push(db.getFilePath())
    } else {
        privNABs.push(db.getFilePath())
    }
    db.recycle()
}
sessionScope.put("ssPublicNABs", pubNABs);
sessionScope.put("ssPrivateNABs", privNABs);

because I use several different Name Pickers on the same page I did not want to repeat having to cycle through the Address books. Then I created 4 NamePicker controls and added 1, 2 , 3 and 4 dominoNABNamePickers providers to each of the successive controls. Then set the rendered property based on the number of public Address books so they would not blow up on me. The db name property on each of the providers is :

var server:String = @Name("[CN]",session.getCurrentDatabase().getServer());
var pubNABs:Array = sessionScope.get("ssPublicNABs");
    return server + "!!" + pubNABs[0];

where pubNABs[n] returns the correct filePath for the NAB. It works well in both Notes Client and the Web. Then to make it not blow up on a local disconnected replica I created 4 more controls and did the same thing but used the privNABs with appropriate rendered properties so that there is no conflict. Seems like the long way around and I'm sure that there is an easier way, but it works.