问题描述
如何转义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 <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>
我想要下面的图片
推荐答案
这是JSF中的一个记录错误. 实际属性被命名为itemEscaped
,而不是escapeItem
(在VDL中未正确记录)或escape
(由于某些未知原因,Eclipse自动完成确实是自动建议的,但实际上完全不存在)在VDL中).
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 <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>
这篇关于如何转义f:selectItem itemLabel属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!