2013-01-09 85 views
5

如何轉義f:SelectItem itemLabel屬性,以便我可以在標籤中添加超鏈接?如何轉義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> 

我想在下面的圖片

enter image description here

回答

14

這是JSF的紀錄片錯誤的東西。 actual attribute被命名爲itemEscaped,而不是escapeItemas incorrectly documented in VDL)或escape(其中Eclipse自動完成確實自動提示出於某些未知原因,但實際上完全不存在於VDL中)。

下面的結構應爲你工作(至少,它爲我的鑽嘴魚科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> 
+5

你是真棒 – Praneeth

+1

不客氣。 – BalusC

+1

我只是修復了文檔錯誤。遲到比晚起更好:https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1107?FocusedWorklogId=24233&page=com.atlassian.jira.plugin.system.issuetabpanels%3Aworklog-tabpanel#worklog-24233 – edburns

相關問題