My bean has a map of Integers to Strings, I am trying to have a menu to select a value to be referred to by a certain key in the map.
My bean looks something like this:
public class Bean {
Map<Integer, String> map;
//...
}
and the relevant portion of my xhtml file looks something like this:
<h:outputLabel value="Selection for code 5" for="code5menu" />
<h:selectOneMenu id="code5menu" value="#{bean.map.get(5)}">
<f:selectItem itemValue="good" itemLabel="good" />
<f:selectItem itemValue="bad" itemLabel="bad" />
</h:selectOneMenu>
Is there a way to do this or something similar?
I can change the bean around some if need be. One thing to note is that the Integers aren't sequential so making a List would have lots of empty space, but if that is the only way I could still try to use a List (the Integer Key wouldn't be the index though). Maybe there's a way to do this with ajax? I looked into EL Functions but that didn't seem like what I needed.