0

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

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

谢谢!

4

1 回答 1

0

我通过向componentType="javax.faces.SelectItrm"`cc:interface 元素添加属性/值来解决它。试试这样:

<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>
于 2015-11-28T12:41:15.533 回答