I have a combo in my page which I want to have populated with some keywords from configuration. I want to use a managed bean to accomplish it.
Let's say that I have a bean called Config, where there is a List categories field. ..
public class Configuration implements Serializable {
private static final long serialVersionUID = 1L;
private List<String> categories;
public List<String> getCategories() {
if (categories == null)
categories = getCats();
return categories;
}
//... etc.
}
When I use this field for my combo, it works well...
<xp:comboBox>
<xp:selectItems>
<xp:this.value><![CDATA[#{config.categories}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
But, it's only a list of labels. I need values, too. How do I populate selectItems of my combo with TWO strings - a label and a value?
EDIT:
I tried to create an object Combo with label and value fields and use a repeat inside my comboBox.
<xp:comboBox>
<xp:repeat id="repeat1" value="#{config.combo}" var="c" rows="30">
<xp:selectItem itemLabel="#{c.label}" itemValue="#{c.value}" />
</xp:repeat>
</xp:comboBox>
Still not working... :-(
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…