如何转义f:selectItem itemLabel属性 [英] How to escape f:selectItem itemLabel attribute

查看:187
本文介绍了如何转义f:selectItem itemLabel属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何转义f:SelectItem itemLabel属性,以便可以在标签中添加超链接?

How to escape f:SelectItem itemLabel attribute so that I can add a hyperlink in the label?

使用以下代码,我可以转义h:outputText,但不能转义f:selectItem.

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>

我想要下面的图片

推荐答案

这是JSF中的一个记录错误.

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).

以下结构应该对您有用(至少在Mojarra 2.1.17上对我有用):

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>

这篇关于如何转义f:selectItem itemLabel属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆