With JSF 2.0, it is now possible to use any class as an item in a selectOneMenu combo and related components. This is described in “Core JavaserverFaces” p157ff. However, the book does not mention that you also need a custom JSF converter to convert between object and string.
If you then implement a custom converter as in the book on p279, e.g. with:-
<h:selectOneMenu styleClass="ss-tsw-select" id="cmbTheme"
value="#{themeSwitcherBean.theme}" disabled="#{themeSwitcherBean.selectDisabled}"
converter="uk.co.salientsoft.thememanager.ThemeConverter"
immediate="true" onchange="submit()">
CDI fails to inject any references used in the converter class, as JSF 2 does not allow CDI in converters, as detailed in this Stack Overflow Post.
It does work however if you use an EL reference in the converter attribute as mentioned in this post here.
Note that the post indicates that it may require it to be an application scoped bean. In my case, it worked fine as both a request scoped and application scoped bean with no trouble. I also removed the @FacesConverter("uk.co.salientsoft.thememanager.Theme") annotation as this was no longer required due to the EL reference. The post indicates that this is perceived to be more untidy due to the use of EL and a managed bean, but I cannot see an issue with this. I cannot see why converters cannot be application scoped CDI beans, it all fits in fine. Here is the code fragment above, modified to use an EL reference instead:-
<h:selectOneMenu styleClass="ss-tsw-select" id="cmbTheme"
value="#{themeSwitcherBean.theme}" disabled="#{themeSwitcherBean.selectDisabled}"
converter="#{themeConverter}"
immediate="true" onchange="submit()">