Class SelectItemsConverter

The omnifaces.SelectItemsConverter allows you to populate a selection component with complex Java
model objects (entities) as value of <f:selectItems> and have JSF convert those
automatically back without the need to provide a custom converter which may need to do the job based on
possibly expensive service/DAO operations. This converter automatically converts based on the Object.toString()
of the selected item.

Usage

This converter is available by converter ID omnifaces.SelectItemsConverter. Just specify it in the
converter attribute of the selection component holding <f:selectItems>.

Make sure that your entity has a good toString() implementation

The base converter uses by default the toString() method of the entity to uniquely identify
the instance during the conversion. This is sufficient if your (abstract base) entity has a
toString() implementation which looks something like this:

If your entity can't have a good toString() implementation

However, if the entity doesn't have a toString() implementation (and thus relies on the default
fqn@hashcode implementation), or the existing implementation doesn't necessarily uniquely
identify the instance, and you can't implement/change it, then it is recommended to extend the
SelectItemsConverter class and override only the getAsString method wherein
the desired implementation is provided. For example:

Again, you do not need to override the getAsObject() method which would only
need to perform possibly expensive service/DAO operations. The SelectItemsConverter base
converter will already do it automatically based on the available items and the getAsString()
implementation.