简体   繁体   English

JSF生命周期。 使用panelGrid来嵌套组件(使用ui:include)

[英]JSF lifecycle. Using panelGrid for nested component (with ui:include)

I have common form with panelGrid: 我与panelGrid有共同的形式:

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

and two nested pages. 和两个嵌套页面。 row1.xhtml: 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>

and row2.xhtml: 和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>

In this case panelGrid work for pages, not for components (outputText and commandButton): 在这种情况下,panelGrid适用于页面,而不适用于组件(outputText和commandButton):

Text (column 1) Button (column 1) 文本(第1列)按钮(第1列)

Text (column 2) Button (column 2) 文本(第2列)按钮(第2列)

But I need this one: 但是我需要这个:

Text (column 1) Button (column 2) 文本(第1列)按钮(第2列)

Text (column 1) Button (column 2) 文本(第1列)按钮(第2列)

I can't have all component in one page, because I pass parameters into nested pages and this is - re used components, but I need support alignment in accordance with the first column. 我无法将所有组件都放在一个页面中,因为我将参数传递到了嵌套页面中,并且这是-重用的组件,但是我需要根据第一列进行对齐。

I use: PrimeFaces 3.5 with JSF 2.1.22 我使用:带有JSF 2.1.22的PrimeFaces 3.5

Thanks in advance! 提前致谢!

I have found an answer on PrimeFaces forum. 我在PrimeFaces论坛上找到了答案。 It should use ui:composition instead of ui:fragment. 它应该使用ui:composition而不是ui:fragment。

"From the docu "ui:fragment is the same as the ui:composition, except for two things: JSF creates a component and adds it directly to the tree, and there's no associated template." “在文档中,“ ui:fragment与ui:composition相同,除了两件事:JSF创建一个组件并将其直接添加到树中,并且没有关联的模板。”

link 链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM