This drives me crazy, cannot find the error.
Here the xhtml page:
...
You can't use enums in combination with h:selectMany***
components without using a converter. JSF/EL does not see/know the generic type of each of the separate list items. In other words, it only sees a List
and not List<Severity>
and treats every item as a String
, unless you tell it to do otherwise.
You need to create and specify a converter yourself. For enums, it's the best to extend the JSF-provided EnumConverter.
package com.example;
import javax.faces.convert.EnumConverter;
import javax.faces.convert.FacesConverter;
@FacesConverter(value="severityConverter")
public class SeverityConverter extends EnumConverter {
public SeverityConverter() {
super(Severity.class);
}
}
(note that when you're still using the old JSF 1.2, you should be declaring this as <converter>
in faces-config.xml
instead of by @FacesConverter
)
Which you use as follows:
<h:selectManyListbox converter="severityConverter">