如何转义f:SelectItem itemLabel
属性,以便可以在标签中添加超链接?
使用以下代码,我可以转义h:outputText
,但不能转义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中的一个记录错误。 actual attribute名为itemEscaped
,而不是escapeItem
(as incorrectly documented in VDL)或escape
(Eclipse自动完成功能确实出于某些未知原因而自动建议使用,但实际上在VDL中完全不存在)。
以下构造应该为您工作(至少在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>
关于jsf - 如何逃避:selectItem itemLabel attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14238646/