In my ResourceBundle i have entries like these:
datasourcegroup.KUNDEN=Kunden
datasourcegroup.INKASSO=Inkasso
datasourcegroup.INTERESSENTEN=Interessenten
datasourcegroup.WARN=Warnadressen
The uppercase parts of the keynames are actually the values of a related Enum type:
public enum DatasourceGroup {
KUNDEN,
INKASSO,
INTERESSENTEN,
WARN;
}
Now in my Facelets pages i would like to access these entries, which is not a problem if i do it with a static keyname, like here:
<h:outputText value="#{msg['datasourcegroup.KUNDEN']}" />
But what i really would like to do is to get the uppercase part of the keyname from a variable, so "semantically" it would be something like this:
<h:outputText value="#{msg['datasourcegroup.#{sessionBean.datasourceGroup}']}" />
But as i learned this is not possible, because EL expressions can't be nested.
Any advice how i could approach this?
Thanks in advance!
regards Mario
EDIT this is the solution i went with:
public String getDatasourceGroupLabel(DatasourceGroup group) {
return "datasourcegroup."+group.toString();
}
<h:outputText value="#{msg[sessionBean.getDatasourceGroupLabel(group)]}" />