How to escape f:selectItems itemLabel attribute

牧云@^-^@ 提交于 2019-12-13 06:35:40

问题


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 &nbsp; 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("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
                        + 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!