java - Why does the backing bean get created twice first time dialog is launched? -



java - Why does the backing bean get created twice first time dialog is launched? -

i using primefaces ui library web ui project.

i have manage_watchfolder.xhtml page has button, , button launches 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 same file have dlgeditwf included edit_watchfolder.xhtml:

<p:dialog id="editdialog" widgetvar="dlgeditwf" dynamic="true"> <ui:include src="edit/edit_watchfolder.xhtml"/> </p:dialog>

i using dynamic=="true" prevent edit_watchfolder.xhtml beingness loaded before button clicked.

editwfform form in edit_watchfolder.xhtml.

problem when launch dialog first time, edit_watchfolder.xhtml backing bean (request scoped) gets created twice. first time value passed editid (see above code) ok, sec time not there, backing bean gets wrong values.

after go (ok or cancel buttons) parent page , launch dialog again, problem gone, ok. problem seems first launch.

why backing bean created twice first time dialog launched?

i suspect because of how primefaces dynamic functionality works.

the first request commandbutton send request parameter editid load. after request occurs , response received , page elements updated, oncomplete javascript occurs displays dialog.

once dialog displayed an exclusively different request occurs dynamically load contents of dialog, except time there no editid parameter. bean @requestscoped hence beingness created twice , sec time not retain editid request parameter.

there 3 possible solutions:

remove dynamic attribute dialog

change bean @viewscoped or @sessionscoped.

change editid request parameter bean property in @sessionscoped managed bean.

java jsf primefaces

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -