Adding the optgroup tag quickly to your xp:combobox

Today I was working on modernizing an xpages application when I came up with a simple enhancement: adding the optgroup tag to a xp:combobox.

By default this option is no available in XPages and if you look around there are some suggestions from hard-coded to DOM modification but I rather looked for a proper JSF implementation.

The data for my combobox resides in a categorized Notes view in a solid NSF so I had two options: navigating through the NotesView via a ViewNavigator (probably next post) or a quick and dirty combo of a dbcolumn and dblookup.

In context with the combobox control the dbcolumn/lookup combo seems suitable 🙂

Here is the simplified setup for my xp:combobox:

As data source I am calling a method on a managed bean. The method is as followed:

The result is nice and straight-forward:

If you questions or difficulties with the implementation, just give me call. Happy development 🙂

Get rid of “Infinity” as the result of a @DbColumn in a combobox – Quicktip

Who has not experienced the following:

XPages has a 32 or 64 ( can’t remember which ) limit for the lookup formula whereas in Notes the limit is only for the whole of the formula e.g. after @unique is applied.

It makes it very hard to have meaningful drop downs for filtering data.

Instead you can use SSJS e.g.:

var lookupView:NotesView = database.getView(“<LOOKUPVIEW>”);

This is the equivalent to:

@DbColumn( “”,”<LOOKUPVIEW>”, 1 );

and returns you the full result without the limit.

But this also brings me to the following problem:

When I enable Select2 on a loooong combobox the list is populated the type-ahead / filtering works fine BUT when I select a value long down the list the response of the select2 combobox becomes really sloooow.

Does anyone has an approach to this?