2012-03-21 46 views
2

我有以下一段代碼,我想呈現radioButtons和他們的標籤。由於由selectOneRadio和selectItem呈現的佈局,我決定使用純HTML作爲輸入radioButton。問題屬性中的h:outputLabel裏面的UI:重複

<h:panelGrid columns="6"> 
    <ui:repeat value="#{myBean.list}" var="item"> 
     <input id="#{item.innerList[0].id}" type="radio" name="radioItem" value="#{item.innerList[0].id}" /> 
     <h:outputLabel for="#{item.innerList[0].id}" value="#{item.label}" /> 
    </ui:repeat> 
</h:panelGrid> 

當試圖分配一個標籤對他們使用outputLabel它呈現的屬性在HTML類似:

j_idt94:0:theidiassigned

的prependId標誌標籤的形式包含此代碼設置爲false,並且在文檔中outputLabel的其他標籤的屬性中沒有這樣的標誌。

+0

」的問題究竟是什麼?肯定有解決方案/變通辦法,等等戰斧'',也http://stackoverflow.com/questions/6033955/jsf-more-customizable-selectmanycheckbox-and-selectoneradio/6034020#6034020見 – BalusC 2012-03-21 18:56:38

回答

2

ui:repeat組分是NamingContainer。它控制着孩子的client identifier

h:outputLabel上的for屬性通常會查找具有匹配組件標識符或客戶端標識符的組件。

所以,對於這個標記:

<foo:someNamingContainer id="x"> 
    <h:inputText id="foo" /> 
    <h:outputLabel for="foo" /> 
</foo:someNamingContainer> 

...標籤會發出匹配,命名空間標識符<label for="...:x:foo"

有一個匹配id匹配的JSF組件,因爲你使用的是直XHTML <input>元素。

只考慮使用XHTML <label>元素來代替。