我正在使用PrimeFaces 3.5並面臨部分頁面呈現問題。我需要將來自Facelet文件的內容加載到模板的「動態」部分。部分頁面呈現(PPR)與臉部重定向
index.xhtml
:
<f:view>
<h:form id="form1">
<p:outputPanel layout="block">
<p:commandButton action="content-2?faces-redirect=false" update="display" />
</p:outputPanel>
<p:outputPanel id="display" layout="block">
content 1
</p:outputPanel>
</h:form>
</f:view>
content-2.xhtml
:
<h:body>
content 2 loaded
</h:body>
當我點擊<p:commandButton>
,然後content-2.xhtml
將被打開。但是,這會刷新整個頁面。 XML響應包含這樣的:
<partial-response><changes><update id="javax.faces.ViewRoot">
當我改變action
屬性的方法表達:
<f:view>
<h:form id="form1">
<p:outputPanel layout="block">
<p:commandButton action="#{myBean.increment}" update="display" />
</p:outputPanel>
<p:outputPanel id="display" layout="block">
#{myBean.count}
</p:outputPanel>
</h:form>
</f:view>
然後display
塊更新預期。 XML響應包含這樣的:
<partial-response><changes><update id="form:display">
爲什麼action="content-2?faces-redirect=false"
方式更新整個頁面?
我也試過<ui:composition>
,但在這種情況下,這會重新加載模板的「靜態」部分。我不想要這個。
你是否暗示'#{myBean.method}'返回'content-2.xhtml'? 'faces-redirect = false'已經是默認了,我不明白你爲什麼明確提到這個。你是否暗示'action =「content-2.xhtml」'的行爲有所不同? – BalusC 2013-04-10 19:56:26
不,對不起,我更新了#{myBean.method}的部分。方法體看起來像'count ++'。我嘗試'action =「content-2.xhtml」'它也刷新'javax.faces.ViewRoot',但是'action =「#{myBean.increment}''refresh'display'。我認爲'faces-redirect = false'必須賦值爲'true'或'false'。 – Mrusful 2013-04-11 17:28:27