2011-07-18 36 views
0

我想創建我自己的selectManyCheckbox複合組件。但是,當我嘗試使用我自己的selectItem組件時,項目將不會呈現。f:selectItem裏面的複合組件

selectItem.xhtml:

<cc:implementation> 

    <f:selectItem rendered="true" id="#{cc.attrs.id}" 
     itemDescription="#{cc.attrs.itemDescription}" 
     itemDisabled="#{cc.attrs.itemDisabled}" 
     itemLabel="#{cc.attrs.itemLabel}" itemValue="#{cc.attrs.itemValue}" 
     value="#{cc.attrs.value}"> 

    </f:selectItem> 

</cc:implementation> 

selectManyCheckbox.xhtml:

<!--Some other stuff like label --> 
<h:selectManyCheckbox styleClass="#{cc.attrs.styleClass}" 
       id="#{cc.attrs.id}_checkbox" value="#{cc.attrs.value}" 
       layout="pageDirection"> 

       <cc:insertChildren /> 
</h:selectManyCheckbox> 

當我使用

<mycomps:selectManyCheckbox id="abc" labelString="Example"> 
       <mycomps:selectItem itemValue="1" itemLabel="One" /> 
      </mycomps:selectManyCheckbox> 

它不工作。但是當我用

<mycomps:selectManyCheckbox id="abc" labelString="Example"> 
       <f:selectItem itemValue="1" itemLabel="One" /> 
      </mycomps:selectManyCheckbox> 

它的確如此!任何人一個想法如何我可以解決這個問題?

謝謝!

+0

我看不到在這樣的複合組件中包裝''1:1的要點。這裏增強了什麼? – BalusC

+0

我只是忽略了其他代碼 – Zinnsoldat

回答

0

我通過在cc:interface元素中添加componentType="javax.faces.SelectItrm"屬性/值來解決這個問題。嘗試是這樣的:

<cc:interface componentType="javax.faces.SelectItem"> 
... 
</cc:interface> 
<cc:implementation> 

    <f:selectItem rendered="true" id="#{cc.attrs.id}" 
     itemDescription="#{cc.attrs.itemDescription}" 
     itemDisabled="#{cc.attrs.itemDisabled}" 
     itemLabel="#{cc.attrs.itemLabel}" itemValue="#{cc.attrs.itemValue}" 
     value="#{cc.attrs.value}"> 

    </f:selectItem> 

</cc:implementation> 
+0

擁有這種1:1組件的優勢是什麼? – Kukeltje