【问题标题】:jsf 2 custom composite component with Primefaces带有 Primefaces 的 jsf 2 自定义复合组件
【发布时间】:2014-02-21 01:59:38
【问题描述】:

我有一个使用 Primefaces 的自定义对话框组件:

myDialog.xhtml

<!-- INTERFACE -->
<cc:interface>

    <cc:attribute name="header" />
    <cc:attribute name="id" />

</cc:interface>

<!-- IMPLEMENTATION -->
<cc:implementation>

    <p:dialog  header="#{cc.attrs.header}"
        id="#{cc.attrs.id}" >


    </p:dialog>


</cc:implementation>

我想在 myDialog 中插入另一个组件,但它不起作用。

example.xhtml

<puc:myDialog  header="Hi" id="myDialogId">
        **This code doesn't appear. Why?**  
        <p:dataGrid>
            <p:row>
                <p:column>
                <p:inputText></p:inputText>
                </p:column>
                </p:row>
        </p:dataGrid>

</puc:myDialog>

【问题讨论】:

  • 您究竟是从哪里读到关于使用id="#{cc.attrs.id}" 废话的?这不是我第一次看到 JSF starter 出于不清楚的原因使用它。因此,一定存在某种劣质资源传播这种错误信息。你能指出它是哪一个,以便我可以联系它的作者吗?

标签: jsf-2 primefaces composite-component


【解决方案1】:

您缺少 cc:insertChildren 标记。

<cc:implementation>
 <p:dialog  header="#{cc.attrs.header}" id="#{cc.attrs.id}" >
  <cc:insertChildren />
 </p:dialog>
</cc:implementation>

使用页面中复合组件标记内的任何子组件或模板文本都将在复合组件:实现部分中此标记的位置指示的位置处重新设置为复合组件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-15
    • 2012-01-29
    • 2013-06-07
    • 2012-07-26
    • 2012-10-02
    • 2011-10-11
    • 2013-04-25
    相关资源
    最近更新 更多