私は PrimeFaces 3.5 を使用していますが、部分的なページ レンダリングで問題が発生しました。Facelet ファイルからテンプレートの「動的」部分にコンテンツをロードする必要があります。
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>
たが、この場合、これはテンプレートの「静的」部分をリロードします。いりません。