如何防止在ajax请求上完全重新呈现视图

时间:2017-11-22 08:08:22

标签: jsf primefaces

我有一个包含Primefaces(6.1)p:layout的主布局页面。对于从该视图发出的每个ajax请求,我发现视图中的所有页面(主布局中的嵌套页面)都将再次重新呈现。我们的想法是仅使用ajax调用呈现当前表单组件或至少当前布局(中心,西方,北方)中的内容。组件使用RequestContext更新,因此对于事件,我根本不会添加更新属性。

这是p:ajax的预期行为还是我错过了什么?另外如何确保PPR实际工作?

UPDATED页面布局(嵌套页面也遵循相同的结构。从未使用过模板)

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>HOME</title>
	<style>
#westPanel {
	z-index: 2 !important;
	padding-left: 0;
	padding-right: 0;
}

#westPanel div {
	overflow: visible;
	padding-left: 0;
	padding-right: 0;
}
</style>

</h:head>

<h:body>

	<h:outputStylesheet name="css/commonStyle.css" />


	<p:layout styleClass="ui-layout-pane-blank" fullPage="true"
		stateful="false" >

		<p:layoutUnit id="northPanel" position="north" size="40" gutter="0"
			resizable="false" closable="false" collapsible="false">
			
				<ui:include src="/store/AMC/header.xhtml"></ui:include>
			
		</p:layoutUnit>

		<p:layoutUnit id="westPanel" position="west" size="300" header="Menu"
			gutter="0" resizable="true" closable="false" collapsible="true">
			<ui:include src="/store/AMC/menu.xhtml"></ui:include>
		</p:layoutUnit>

		<p:layoutUnit id="centerPanel" gutter="0" position="center">
			<h:form id="centralForm">
				<ui:include src="#{centralLayoutMB.centralLayout}.xhtml" />
			</h:form>
		</p:layoutUnit>

	</p:layout>


	<p:ajaxStatus onstart="PF('statusDialog').show()"
		onsuccess="PF('statusDialog').hide();" />

	<p:dialog widgetVar="statusDialog" draggable="false" closable="false"
		resizable="false" showHeader="false">
		<p:graphicImage url="/resources/images/icons/load.gif" />

	</p:dialog>

</h:body>


</html>

DEBUG CONSOLE OUTPUT

2017-11-22 10:15:01 INFO stdout:71 - START PHASE RESTORE_VIEW 1

2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/masterLayout.xhtml @7,9 <h:head> Component[-2048881072_7a1f71a3] Created: javax.faces.component.UIOutput
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/masterLayout.xhtml @25,9 <h:body> Component[-2048881072_7a1f7189] Created: javax.faces.component.html.HtmlBody
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/masterLayout.xhtml @27,51 <h:outputStylesheet> Component[-2048881072_7a1f71ef] Created: javax.faces.component.UIOutput
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/masterLayout.xhtml @31,48 <p:layout> Component[-2048881072_7a1f71e2] Created: org.primefaces.component.layout.Layout
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/masterLayout.xhtml @34,59 <p:layoutUnit> Component[-2048881072_7a1f71c8] Created: org.primefaces.component.layout.LayoutUnit
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @7,26 <h:form> Component[-1732486783_6925632b] Created: javax.faces.component.html.HtmlForm
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @9,67 <p:hotkey> Component[-1732486783_69256305] Created: org.primefaces.component.hotkey.Hotkey
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @11,47 <p:toolbar> Component[-1732486783_69256370] Created: org.primefaces.component.toolbar.Toolbar
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @14,63 <h:panelGrid> Component[-1732486783_69256344] Created: javax.faces.component.html.HtmlPanelGrid
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @16,20 <p:commandLink> Component[-1732486783_692563be] Created: org.primefaces.component.commandlink.CommandLink
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @18,50 <p:graphicImage> Component[-1732486783_69256398] Created: org.primefaces.component.graphicimage.GraphicImage
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @28,47 <p:commandButton> Component[-1732486783_692563e1] Created: org.primefaces.component.commandbutton.CommandButton
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @33,49 <p:commandButton> Component[-1732486783_692563ec] Created: org.primefaces.component.commandbutton.CommandButton
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @38,48 <p:commandButton> Component[-1732486783_692563db] Created: org.primefaces.component.commandbutton.CommandButton
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @43,42 <p:menuButton> Component[-1732486783_692563c6] Created: org.primefaces.component.menubutton.MenuButton
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @47,45 <p:menuitem> Component[-1732486783_69256220] Created: org.primefaces.component.menuitem.UIMenuItem
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @51,51 <p:menuitem> Component[-1732486783_6925622f] Created: org.primefaces.component.menuitem.UIMenuItem
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @56,52 <p:menuitem> Component[-1732486783_6925621a] Created: org.primefaces.component.menuitem.UIMenuItem
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @60,44 <p:menuitem> Component[-1732486783_69256209] Created: org.primefaces.component.menuitem.UIMenuItem
2017-11-22 10:15:01 DEBUG component:485 - /store/AMC/header.xhtml @65,49 <p:menuitem> Component[-1732486783_69256274] Created: org.primefaces.component.menuitem.UIMenuItem

等等......直到遇到ajax事件。

0 个答案:

没有答案