I've the below dialog:
<h:form id="r1">
<p:commandButton value="Basic" type="button" onclick="PF('dlg1').show();" />
<p:dialog header="Basic Dialog" widgetVar="dlg1">
<h:outputText id="test" value="Welcome to PrimeFaces" />
</p:dialog>
</h:form>
How can I refresh the JSF page after closing the dialog?
The <p:dialog>
supports the ajax close
event. This only requires it being placed inside a <h:form>
(on contrary to the general recommendation), so you need to make sure that it's already manually poisitioned to the very end of the <h:body>
and that you don't make use of appendToBody
.
<h:body>
<h:panelGroup id="content" layout="block">
...
</h:panelGroup>
...
<h:form>
<p:dialog>
<p:ajax event="close" update=":content" />
...
</p:dialog>
</h:form>
</h:body>
Use if necessary update="@all"
if you intend to update the entire page. But better is to update only the parts which really need to be updated.