Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape f:selectItem itemLabel attribute

Tags:

jsf

jsf-2

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 &lt;a href=&quot;http://google.com&quot; &gt;Google &lt;/a&gt;" escape="false"/>              
            <h:selectOneRadio id="p" value="#{bean.somevalue}" required="true" >
                <f:selectItem escape="false" escapeItem="false" itemLabel="One &lt;a href=&quot;http://google.com&quot; &gt;Google &lt;/a&gt;" itemValue="O" />
                <f:selectItem escape="false" escapeItem="false" itemLabel="Two &lt;a href=&quot;http://stackoverflow.com&quot; &gt;Stackoverflow&lt;/a&gt;" itemValue="T" />
            </h:selectOneRadio>

I want something as in following image

enter image description here

like image 939
Praneeth Avatar asked Jan 09 '13 15:01

Praneeth


1 Answers

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 &lt;a href=&quot;http://google.com&quot; &gt;Google &lt;/a&gt;" itemValue="O" />
    <f:selectItem itemEscaped="false" itemLabel="Two &lt;a href=&quot;http://stackoverflow.com&quot; &gt;Stackoverflow&lt;/a&gt;" itemValue="T" />
</h:selectOneRadio>
like image 167
BalusC Avatar answered Oct 16 '22 03:10

BalusC