f:复合组件内的selectItem

时间:2011-07-18 11:15:38

标签: jsf checkbox jsf-2 composite-component

我正在尝试使用复合组件创建自己的selectManyCheckbox。但是当我尝试使用自己的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>

确实如此!有人知道如何解决这个问题吗?

谢谢!

1 个答案:

答案 0 :(得分: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>
相关问题