【问题标题】:JSF lifecycle. Using panelGrid for nested component (with ui:include)JSF 生命周期。将 panelGrid 用于嵌套组件(使用 ui:include)
【发布时间】:2013-05-29 17:58:17
【问题描述】:

我和panelGrid有共同的形式:

<h:form id="formId">
            <p:panelGrid columns="2" id="sdf">
                         <ui:include src="row1.xhtml"/>
                         <ui:include src="row2.xhtml"/>
                     </p:panelGrid>
 </form>

和两个嵌套页面。 row1.xhtml:

<ui:fragment xmlns="http://www.w3.org/1999/xhtml"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:p="http://primefaces.org/ui">
    <h:outputText value="Text  (column 1)"/>
    <p:commandButton value="Batton (column 1)"/>
</ui:fragment>

和row2.xhtml:

<ui:fragment xmlns="http://www.w3.org/1999/xhtml"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:p="http://primefaces.org/ui">
    <h:outputText value="Text  (column 2)"/>
    <p:commandButton value="Batton (column 2)"/>
</ui:fragment>

在这种情况下,panelGrid 适用于页面,而不适用于组件(outputText 和 commandButton):

文本(第 1 列)按钮(第 1 列)

文本(第 2 列)按钮(第 2 列)

但我需要这个:

文本(第 1 列)按钮(第 2 列)

文本(第 1 列)按钮(第 2 列)

我不能在一个页面中包含所有组件,因为我将参数传递到嵌套页面中,这是 - 重复使用的组件,但我需要支持按照第一列对齐。

我使用:PrimeFaces 3.5 和 JSF 2.1.22

提前致谢!

【问题讨论】:

    标签: java jsf jsf-2 primefaces uicomponents


    【解决方案1】:

    我在 PrimeFaces 论坛上找到了答案。它应该使用 ui:composition 而不是 ui:fragment。

    “来自文档”ui:fragment 与 ui:composition 相同,除了两件事:JSF 创建一个组件并将其直接添加到树中,并且没有关联的模板。”

    link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-04
      • 2010-09-07
      • 2011-05-16
      • 1970-01-01
      • 2015-05-06
      • 2016-09-01
      • 1970-01-01
      相关资源
      最近更新 更多