问题
I'm using a name picker in my XPages to allow an easy selection of people and groups. Here's my code:
<xe:namePicker id="namePicker1" for="Receiver">
<xe:this.dataProvider>
<xe:dominoNABNamePicker groups="true" nameList="peopleAndGroups" people="true"></xe:dominoNABNamePicker>
</xe:this.dataProvider>
<xe:this.rendered><![CDATA[#{javascript:docApplication.getItemValueString("ZwfStepNumber") == 1}]]></xe:this.rendered></xe:namePicker>
If I use "peopleAndGroups" as nameList property, all names are listed by first name. But I want them by last name. So if I use "peopleAsLastName" at least I get them as I want, but without groups.
So how do I get a list of all people by last name and all groups? Or how can I solve this problem? Any ideas?
回答1:
You can create your own name picker bean with the wanted behavior.
You need to create a Java class that implements the INamePickerData
interface. Although it is called a bean, you do not need to register it in faces-config.xml. The important method is the readEntries()
method which returns your custom name picker data. Here's a simplified example:
public IPickerResult readEntries(final IPickerOptions options) {
List<IPickerEntry> entries = new ArrayList<IPickerEntry>();
entries.add(new SimplePickerResult.Entry("CN=Person A/O=Org", "Person A");
entries.add(new SimplePickerResult.Entry("CN=Person B/O=Org", "Person B");
return new SimplePickerResult(entries, -1);
}
You can then use your custom name picker by using the beanNamePicker dataProvider. Here's a simplified example:
<xe:namePicker id="namePickerBean">
<xe:this.dataProvider>
<xe:beanNamePicker>
<xe:this.dataBean><![CDATA[com.company.MyNamePicker]]></xe:this.dataBean>
</xe:beanNamePicker>
</xe:this.dataProvider>
</xe:namePicker>
There's an OpenNTF XSnippet with a more complete example of a name picke bean.
回答2:
It doesn't look like that's an option, although there is a view in the Domino Directory, $PeopleGroupsFlat, which provides that data. It looks like the name Picker is using the $VIM... views.
The only way round it I can see is to use the namePickerAggregator dataProvider, and allow users to switch between People By Last Name and Groups. (Extending a dataProvider for Name Picker or Value Picker is not straightforward, because a lot of methods and inner classes are protected.)
It's worth adding it as a feature request to the Extension Library project on OpenNTF. I've added it as an issue on OpenNTF Domino API. We're already extending the Name Picker, so I'll look at adding it into there as well
来源:https://stackoverflow.com/questions/24204106/dojo-name-picker-people-by-last-name-and-groups