我有一个共同的形式与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):
Text (column 1)按钮(column 1)
文本(第二列)按钮(第二列)
但是我需要这个:
文本(第一列)按钮(第二列)
文本(第一列)按钮(第二列)
我不能在一个页面中拥有所有组件,因为我将参数传递到嵌套的页面中,这是重复使用的组件,但我需要根据第一列支持对齐。
我使用:PrimeFaces 3.5 with JSF 2.1.22
提前感谢!
我在PrimeFaces论坛上找到了答案。它应该使用ui:composition而不是ui:fragment。
"From the docu "ui:fragment与ui:composition相同,除了两件事:JSF创建一个组件并将其直接添加到树中,并且没有关联的模板。"
链接