Nested dialogs are supported to allow creating a dialog from another dialog. Demo here has 3 level of nested dialogs where last dialog returns data back to the root.
<h:form id="rootform">
<p:growl id="growl" showDetail="true"/>
<div class="card">
<h5>DialogReturn with Button</h5>
<p:commandButton id="btn" value="View" icon="pi pi-home" action="#{dfRootView.openLevel1}">
<p:ajax event="dialogReturn" listener="#{dfRootView.onReturnFromLevel1}" update="growl"/>
</p:commandButton>
</div>
<div class="card">
<h5>DialogReturn with Link</h5>
<p:commandLink id="lnk" value="View" action="#{dfRootView.openLevel1}" styleClass="p-text-bold">
<p:ajax event="dialogReturn" listener="#{dfRootView.onReturnFromLevel1}" update="growl"/>
</p:commandLink>
</div>
<div class="card">
<h5>DialogReturn with a Menu</h5>
<p:menu>
<p:submenu label="Dialog Framework">
<p:menuitem value="View" action="#{dfRootView.openLevel1}">
<p:ajax event="dialogReturn" listener="#{dfRootView.onReturnFromLevel1}" update="growl"/>
</p:menuitem>
</p:submenu>
</p:menu>
</div>
</h:form>
@Named("dfRootView")
@RequestScoped
public class DFRootView {
public void openLevel1() {
Map<String,Object> options = new HashMap<String, Object>();
options.put("modal", true);
PrimeFaces.current().dialog().openDynamic("level1", options, null);
}
public void onReturnFromLevel1(SelectEvent event) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Data Returned", event.getObject().toString()));
}
}