【问题标题】:Nested insertChildren composite嵌套 insertChildren 复合
【发布时间】:2015-02-17 18:08:53
【问题描述】:

我有两个嵌套复合

复合A

<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
    xmlns:composite="http://java.sun.com/jsf/composite">

    <composite:interface>
    </composite:interface>
    <composite:implementation>
        <composite:insertChildren />
        <p:separator />
    </composite:implementation>
</ui:composition>

和复合B

(案例#1)

<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
    xmlns:mycomposites="http://java.sun.com/jsf/composite/mycomposites"
    xmlns:composite="http://java.sun.com/jsf/composite">

    <composite:interface>
    </composite:interface>
    <composite:implementation>
        <mycomposites:a>
            <composite:insertChildren />
        </mycomposites:a>
    </composite:implementation>

</ui:composition>

终于有了我的视图或页面

<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
    xmlns:gt="http://java.sun.com/jsf/composite/template"
    xmlns:mycomposites="http://java.sun.com/jsf/composite/mycomposites"
    template="/template/template.xhtml">

    <ui:define name="body">
        <mycomposites:b>
            <h:outputText value="test" />
        </mycomposites:b>
    </ui:define>

</ui:composition>

“测试”未呈现。 对于我所看到的,这是因为 B 中的 insertChildren 在另一个复合材料 insertChildren (A) 中。

如果我将 B 中的 insertChildren 移动到复合材料之外,则可以正常工作,如下所示:

(案例#2)

<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
    xmlns:mycomposites="http://java.sun.com/jsf/composite/mycomposites"
    xmlns:composite="http://java.sun.com/jsf/composite">

    <composite:interface>
    </composite:interface>
    <composite:implementation>
        <mycomposites:desktop>
            <!-- MOVED -->
        </mycomposites:desktop>
        <composite:insertChildren />
    </composite:implementation>
</ui:composition>

但是 CASE #2 对我没有多大帮助。我需要它,就像案例 #2 一样

有什么帮助吗?

谢谢

【问题讨论】:

    标签: jsf composite-component


    【解决方案1】:

    我和你有同样的问题。

    我有一个组件A.xhtml

    <composite:implementation>
      <primefaces:datatable>
        <primefaces:column>
          <h:outputText value="#{row.identityName}" />
        </primefaces:column>
        <composite:insertChildren />
      </primefaces:datatable>
    </composite:implementation>
    

    在三个文件中使用:

    • common/approve.xhtml
    • 身份/技术/search.xhtml
    • 身份/业务/search.xhtml

    在“identity/*/search.xhtml”页面中,我为组件 A 提供了许多相同的属性和子项。 因为这会产生很多重复的代码,所以我尝试为两个身份页面制作组件 A 的 s 子组件。

    identity_A.xhtml

    <composite:implementation>
      <component:A identityAttribute="example">
        <primefaces:column>
          <h:outputText value="#{row.identityName}" />
        </primefaces:column>
        <composite:insertChildren />
      </component:A>
    </composite:implementation>
    

    我注意到,我提供给 identity_A.xhtml 的孩子不再显示在 primefaces 数据表中。

    我对这个问题的解决方案/解决方法是为这两个页面创建一个模板,而不是一个子组件:

    identitySearch.xhtml

    ...
    <component:A identityAttribute="example">
      <primefaces:column>
        <h:outputText value="#{row.identityName}" />
      </primefaces:column>
      <ui:insert name="datatableChildren">
    </component:A>
    ...
    

    也许你可以像我一样解决你的问题。 我希望会有一个解决方案,在嵌套复合组件中使用composite:insertChildren

    【讨论】:

      猜你喜欢
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 2015-08-25
      • 1970-01-01
      • 2014-03-07
      • 2011-03-08
      相关资源
      最近更新 更多