JSF-2 f: wybierz opcję Elementy z mapą nie wyświetla elementu LabelLab
Kiedy używam f: selectItems, aby wyświetlić elementy na mapie, nie mogę wyświetlić wartości elementu mapy, tylko klucza. f: selectItems w ogóle nie używa elementu itemLabel. Kiedy korzystam z listy, to wszystko działa.
Poniższe czynności wykorzystują element itemLabel do wyświetlenia „opisu” przedmiotu na liście:
<h:selectOneMenu>
<f:selectItems value="#{testBB.testList}" var="s"
itemLabel="TEST #{s.description}" itemValue="#{TEST s.name}" />
</h:
selectOneMenu>
Następująca próba wyświetlenia wartości elementu na mapie nie działa. Wyświetla klucz elementu, ale nie używa atrybutu itemLabel, co można zauważyć w wyniku braku tekstu „TEST”.
<rich:select>
<f:selectItems value="#{testBB.testMap}" var="s"
itemLabel="TEST #{s.value}" itemValue="TEST #{s.key}" />
</rich:select>
Zastosowano prostą fasolę bazową:
public class TestBB {
private Map<String, String> testMap;
private List<TestItem> testList;
public TestBB() {
testMap = new HashMap<String, String>();
testMap.put("1_key", "Item One");
testMap.put("2_key", "Item Two");
testMap.put("3_key", "Item Three");
testList = new ArrayList<TestItem>();
testList.add( new TestItem("name_1", "description_1") );
testList.add( new TestItem("name_2", "description_2") );
testList.add( new TestItem("name_3", "description_3") );
}
public Map<String, String> getTestMap() {
return testMap;
}
public List<TestItem> getTestList() {
return testList;
}
}
Tak więc wszelkie pomysły na to, jak wykonać tę pracę, czyli jak efektywnie korzystać z mapy z selectItems?