I have generic class with this signature:
public abstract class EnumListBean<E extends Enum<E>> {
public List<E> getEnumList() {
//implementation details
}
}
Currently I have to define a empty subclass in order to access the enumList property for a concrete generic parameter:
@ManagedBean
@ApplicationScoped
public class ItemRarityBean extends EnumListBean<Item.Rarity>{
}
This makes its possible to access the property e.g:
<f:selectItems value="#{itemRarityBean.enumList}" var="rarity"
itemLabel="#{rarity.readableName}" itemValue="#{rarity}" />
Im wondering whether one really have to declare a deriving bean but cant access the generic class as bean directly:
<f:selectItems value="#{enumListBean<Item.Rarity>.enumList}" var="rarity"
itemLabel="#{rarity.readableName}" itemValue="#{rarity}" />
<o:importConstants>
useful. – Jakienew EnumListBean<Item.Rarity>.getEnumList()
to return anything else thannew EnumListBean<SomethingElse>.getEnumList()
without passing a type token because of type erasure. What you could do is fake an indexed property and have a bean indexable by aClass
that returns the list of its values, but I'm not sure whether you can use class literals in EL. – Burthen<o:importConstants>
imported enum even be used as list in conjunction with<f:selectItems>
? – Method