I am using PrimeFaces UI library for my web UI project.
I have a manage_watchfolder.xhtml
page that has a button, and this button launches a dialog:
<p:commandButton value="Add" oncomplete="dlgEditWF.show()" update=":editWFForm">
<f:param value="#{item.value.ID}" name="editId"/>
<h:graphicImage value="./edit.png" />
</p:commandLink>
Inside this same file I have dlgEditWF
included from edit_watchfolder.xhtml
:
<p:dialog id="editDialog" widgetVar="dlgEditWF" dynamic="true">
<ui:include src="edit/edit_watchfolder.xhtml"/>
</p:dialog>
I am using dynamic=="true"
to prevent edit_watchfolder.xhtml
from being loaded before the button is clicked.
editWFForm
is a form in edit_watchfolder.xhtml
.
Problem is that when I launch the dialog for the first time, the edit_watchfolder.xhtml
backing bean (request scoped) gets created twice. First time the value passed with editId
(see above code) is OK, but second time it is not there, so the backing bean gets wrong values.
After I go back (OK
or Cancel
buttons) to the parent page and launch the dialog again, the problem is gone, all is OK. The problem seems to be only the first launch.
Why does the backing bean get created twice first time dialog is launched?