问题
How do I escape f:selectItems itemLabel to use HTML markup? Below is the code
<h:selectManyListbox
id="geographicLoc"
value="#{handlerBean.selectedGeographicLoc}">
<a4j:ajax event="change" render="citiesID" status="newState" />
<f:selectItem
itemLabel="All All"
itemValue="All" itemEscaped="false"/>
<f:selectItems
value="#{handlerBean.geographicLocList}"
itemEscaped="false"/>
</h:selectManyListbox>
The attribute itemEscaped is working for f:selectItem but not for f:selectItems.
In backingbean, geographicLocList is of type SelectItem list and I am trying to add in java as below
final SelectItem selectItemS = new SelectItem();
selectItemS.setLabel(" "
+ country.getStateDesc());
selectItemS.setValue(country.getStateCode());
geographicLocList.add(selectItemS);
回答1:
As per the <f:selectItems> tag documentation, you need the itemLabelEscaped
attribute for this.
<f:selectItem ... itemEscaped="false" />
<f:selectItems ... itemLabelEscaped="false" />
See also:
- How to escape f:selectItem itemLabel attribute
来源:https://stackoverflow.com/questions/31216907/how-to-escape-fselectitems-itemlabel-attribute