jsf - Update tag generate multiple dialog instances in appendTo="@(body)" dialogs -
i've following error running on pf 5.1:
when update div contains
<p:dialog appendto="@(body)" .... ></p:dialog>
it generates duplicated dialog in dom
example
main.xhtml
<h:body> <ui:composition template="/templates/layout.xhtml"> <ui:define name="content"> <h:form id="formgrowl"> <p:growl id="growl" showdetail="true" showsummary="false" autoupdate="true" /> </h:form> <h:panelgroup id="mainpanel" style="background: #ffffff;" layout="block"> <p:scrollpanel mode="native"> <h:panelgroup layout="block" style="padding: 1em;"> <p:commandbutton value="go page dialog" action="#{mycontroller.gotopagewithdialog}" update=":mainpanel"></p:commandbutton> </h:panelgroup> <c:if test="#{mycontroller.renderpagewithdialog}"> <h:panelgroup> <ui:include src="/pagewithdialog.xhtml"></ui:include> </h:panelgroup> </c:if> </ui:define> </ui:composition> </h:body> </html>
pagewithdialog.xhtml
<h:body> <ui:composition> <h:form> <p:panel> <h:panelgrid columns="2"> <h:outputlabel value="hello" /> <p:inputtext value="#{mycontroller.name}"></p:inputtext> </h:panelgrid> <p:panel> <p:commandbutton value="back" action="#{mycontroller.goback}" update=":mainpanel"></p:commandbutton> <p:commandbutton value="#{diccionariobean.msg['comunes.continuar']}" style="float:right;" process="@form" oncomplete="pf('dialog').show();"></p:commandbutton> </p:panel> </p:panel> </p:panel> </h:form> <p:dialog id="iddialog" widgetvar="dialog" modal="true" appendto="@(body)" header="confirm" closable="false" width="400"> <h:form> <h:panelgroup layout="block"> <strong>are u sure?</strong> <p:separator /> <h:panelgroup layout="block" style="text-align:center;"> <p:commandbutton value="yes" process="@this" action="#{mycontroller.action}" update=":formgrowl"></p:commandbutton> <p:commandbutton value="no" oncomplete="pf('dialog').hide();"></p:commandbutton> </h:panelgroup> </h:form> </p:dialog> </ui:composition> </h:body>
clicking gotopagewithdialog -> button -> gotopagewithdialog -> renders dialog twice in dom. (and many times repeat action)
ok, solve problem,
i put styleclass="body-dialog"
on dialog,
and execute following js in button method
requestcontext.getcurrentinstance().execute("$('.body-dialog').destroy();");
i know it's posible better composition , include once in separated form or panel , update panel.
my question thought appendto body tag must replace dialog if has same id new 1 trying render in dom in 5.1 version saw in post.
if area jsf rendered primefaces component updated using jsf's ajax feature, jsf remove area update dom, render component again, not know moved elsewhere. in old versions of primefaces, caused component appear in dom twice (with same id), caused problems later submits. fixed primefaces 4.0 ( issue 5636: dialog appendtobody & dynamic doesn't remove old dom element ), re-occurred in 5.0 (issue #367).
Comments
Post a Comment