This is a pattern that I would use over and over again if I get it to work. I have an enum name Log.LogKey that I want to user to pick out instances of. So the facelet has
You need to specify a converter. JSF EL is not aware about the generic List
type because that's lost during runtime. When you do not explicitly specify a converter, JSF will not convert the submitted String
values and plain fill the list with them.
In your particular case, you can make use of the JSF builtin EnumConverter, you just have to super()
the enum type in the constructor:
package com.example;
import javax.faces.convert.EnumConverter;
import javax.faces.convert.FacesConverter;
@FacesConverter(value="logKeyConverter")
public class LogKeyConverter extends EnumConverter {
public LogKeyConverter() {
super(Log.LogKey.class);
}
}
To use it, just declare it as follows:
<h:selectManyCheckbox value="#{test.selectedKeys}" converter="logKeyConverter">
...
</h:selectManyCheckbox>