How to escape f:selectItem itemLabel attribute
How to escape f:SelectItem itemLabel
attribute so that I can add a hyperlink in the label?
Using following code, I was able to escape h:outputText
but not f:selectItem
.
<h:outputText value="MyLink <a href="http://google.com" >Google </a>" escape="false"/>
<h:selectOneRadio id="p" value="#{bean.somevalue}" required="true" >
<f:selectItem escape="false" escapeItem="false" itemLabel="One <a href="http://google.com" >Google </a>" itemValue="O" />
<f:selectItem escape="false" escapeItem="false" itemLabel="Two <a href="http://stackoverflow.com" >Stackoverflow</a>" itemValue="T" />
</h:selectOneRadio>
I want something as in following image
Solution 1:
This is a documentary bug in JSF. The actual attribute is named itemEscaped
, not escapeItem
(as incorrectly documented in VDL) or escape
(which Eclipse autocomplete indeed autosuggests for some unknown reason, but is actually totally absent in VDL).
The following construct should work for you (at least, it does for me on Mojarra 2.1.17):
<h:selectOneRadio>
<f:selectItem itemEscaped="false" itemLabel="One <a href="http://google.com" >Google </a>" itemValue="O" />
<f:selectItem itemEscaped="false" itemLabel="Two <a href="http://stackoverflow.com" >Stackoverflow</a>" itemValue="T" />
</h:selectOneRadio>