jsf - 如何逃避:selectItem itemLabel attribute

标签 jsf jsf-2

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

使用以下代码,我可以转义h:outputText,但不能转义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中的一个记录错误。 actual attribute名为itemEscaped,而不是escapeItem(as incorrectly documented in VDL)或escape(Eclipse自动完成功能确实出于某些未知原因而自动建议使用,但实际上在VDL中完全不存在)。

以下构造应该为您工作(至少在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>

关于jsf - 如何逃避:selectItem itemLabel attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14238646/

相关文章:

css 边距不适用于 jsf

jsf - 注入(inject) vs ManagedProperty

jsf-2 - Primefaces TabView 在第三次加载选项卡时抛出空指针

java - JSF/莫贾拉 2.0.2 : ui:repeat is totally broken when updating via AJAX

jsf - SelectManyCheckbox onHide with remoteCommand

javascript - ajaxOncomplete后触发ajax调用会导致无限循环

jsf - 在 "update"为假之后,Ajax "render"是否正常?

jsf - @ViewScoped 的 @PostConstruct 在每个请求上被调用

java - 服务器发起的渲染 : EJB -> FacesContext?

jsf-2 - <ui :include> with variable number of method parameters 中的参数化方法调用