I'm using PrimeFaces 3.5 and I faced a problem with partial page rendering. I need to load content from a Facelet file into "dynamic" part of a template.
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>
When I click on the <p:commandButton>
, then content-2.xhtml
will be opened. However, this refreshes the whole page. The XML response contains like this:
<partial-response><changes><update id="javax.faces.ViewRoot">
When I change the action
attribute to a method expression:
<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>
Then the display
block updates as expected. The XML response contains like this:
<partial-response><changes><update id="form:display">
Why does the action="content-2?faces-redirect=false"
way update the entire page?
I also tried to <ui:composition>
, but in this case this reloads "static" part of template. I do not want it.