我遇到PrimeFaces AJAX和UI问题:包括。我正在尝试使用标签ui执行基于AJAX的Web表单:include:当我单击菜单按钮时,它会更改包含的SRC并加载下一页。一切都运行正常,但是当我尝试在ui:include加载的页面上使用某些AJAX时,它不会更新。好吧,我认为代码会显示我在说什么:
主页:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>PrimeFaces</title>
</f:facet>
<ui:include src="#{layout.head}"></ui:include>
</h:head>
<h:body>
<h:form>
<p:layout fullPage="true" >
[...]
<p:layoutUnit position="center">
<p:panel styleClass="noBorder" id="#{pageFlow.panelId}">
<ui:insert name="mainContent">
<ui:include src="#{pageFlow.page}"/>
</ui:insert>
</p:panel>
</p:layoutUnit>
</p:layout>
<p:growl id="globalMessages" showDetail="true" severity="warn, error, fatal" autoUpdate="true"></p:growl>
</h:form>
</h:body>
</f:view>
</html>
template.xhtml - 要加载的页面包括:
<ui:fragment
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:messages id="resultMessage" showDetail="true" severity="info" autoUpdate="true" closable="true"/>
<p:panel styleClass="noBorder">
<p:panel id="templateBody" header="Cadastro de Template" style="margin: 10px">
<h:panelGrid cellpadding="3">
<p:row>
<p:column><h:outputLabel value="Nome: "/></p:column>
<p:column><p:inputText value="#{template.name}"/></p:column>
<p:column><h:outputLabel value="Descrição: "/></p:column>
<p:column><p:inputText value="#{template.description}"/></p:column>
</p:row>
<p:row><p:column><p:separator/></p:column></p:row>
<p:row>
<p:column><h:outputLabel style="vertical-align: middle" value="Provedor: "/></p:column>
<p:column>
<p:selectOneMenu style="vertical-align: middle" validator="selectOneMenuValidator" converter="selectOneMenuConverter" id="providers" value="#{template.providerName}">
<f:selectItems value="#{template.testItems}"/>
<f:attribute name="fieldName" value="template.providerName"/>
<p:ajax update="selectAvaliableItems"/>
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
<p:panel id="selectItem" styleClass="noBorder" style="alignment-adjust: central; float: left; height: 200px; width: 100%">
<p:selectManyMenu converter="selectManyMenuConverter" validator="selectManyMenuValidator" value="#{template.selectedAvaliableItems}" style="float: left; height: 180px; width: 300px" id="selectAvaliableItems">
<f:selectItems value="#{template.avaliableItems}"/>
<f:attribute name="fieldName" value="template.selectedAvaliableItems"/>
</p:selectManyMenu>
<p:panel styleClass="noBorder" style="float: left; height: 180px; width: 75px">
<p:commandButton value=">>" update="selectItem" actionListener="#{template.setAction(8+0)}"/>
<p:commandButton value=">" update="selectItem" actionListener="#{template.setAction(8+1)}"/>
<p:commandButton value="<" update="selectItem" actionListener="#{template.setAction(16+1)}"/>
<p:commandButton value="<<" update="selectItem" actionListener="#{template.setAction(16+0)}"/>
</p:panel>
<p:selectManyMenu converter="selectManyMenuConverter" validator="selectManyMenuValidator" value="#{template.selectedChosenItems}" style="float: left;height: 180px; width: 300px" id="selectSelectedItems">
<f:selectItems value="#{template.chosenItems}"/>
<f:attribute name="fieldName" value="template.selectedChosenItems"/>
</p:selectManyMenu>
</p:panel>
</p:column>
</p:row>
<p:row>
<p:column>
<p:commandButton id="saveBtn" value="Salvar" update="templateBody" action="#{template.sendData}"/>
</p:column>
<p:column>
<p:commandButton value="Cancelar" update="@all" action="home"/>
</p:column>
</p:row>
</h:panelGrid>
</p:panel>
</p:panel>
<p:blockUI block="templateBody" trigger="saveBtn providers">
<p:graphicImage value="./files/img/todo/loading.gif" />
</p:blockUI>
</ui:fragment>
flowPage bean可以正常工作,它会在单击MenuButton的基础上返回一个带有要加载的文件名的String。问题是template.xhtml上的每个AJAX都不会更新其内容。调用了blockUI,我收到了一个请求,但没有内容更新......
有什么想法吗?
如果我删除了ui:include并使用模板策略,它工作正常,但我想要一个AJAX导航页面。
请你注意。