jsf - View scoped managed bean's @PostConstruct reinvoked after closing p:dialog -


i have popup defined within xhtml gets shown conditionally depending on selections user makes in main screen rendered default:

<p:dialog id="commentdialogid" header="enter comment" widgetvar="commentdialog" modal="true" resizable="true" height="auto">     <h:form id="commentform">          <h:outputlabel for="comment" value="comment:"/>          <p:inputtextarea id="comment" title="comment"                  rows="6" cols="33"                 value="#{managedbean.activeitem.comment}"                 required="true">             <f:ajax render="comment"/>         </p:inputtextarea>          <h:commandbutton id="commentsubmit" value="submit" action="#{managedbean.proceed}" onclick="pf('commentdialog').hide();">             <f:ajax render="commentsubmit"/>         </h:commandbutton>      </h:form> </p:dialog> 

the problem that, once dialog/popup closed, container (jboss) or framework (jsf/primefaces), not sure which, thinks whole view has been closed , therefore on next request triggers appearance of popup, re-invokes backing bean's @postconstruct method. backing bean @viewscoped. don't want that, instead, want treat dialog/popup div in page closure not affect view state.

the first time dialog brought up, @postconstruct not invoked initial view rendering page, called @postconstruct, still active. however, on second appearance, reinvoked, leads me believe because closed after first time, either container of framework or both mistake needing reload bean.

what can prevent backing bean going @postconstruct after dialog has been closed?

i know problem is..
using h:commandbutton submit form , close dialog.
lets @ code:

<h:commandbutton id="commentsubmit" value="submit" action="#{managedbean.proceed}" onclick="pf('commentdialog').hide();">     <f:ajax render="commentsubmit"/> </h:commandbutton> 

in above code clikc submit button:
1. action triggred call managedbean method managedbean.proceed.
2. since have bound onclick js event, dialog gets closed.

after action="#{managedbean.proceed} comes has update button id commentsubmit since have used render="commentsubmit".
time action="#{managedbean.proceed} comes render="commentsubmit" disloag in button commentsubmit placed closed. might reason re initializing managedbean.

to avoid ca use primefaces p:commandbutton has oncomplete attribute helpfull in scenario.

<p:commandbutton id="commentsubmit" value="submit" action="#{managedbean.proceed}" update="commentsubmit" oncomplete="pf('commentdialog').hide();" /> 

so in above case p:dialog close after action completed.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -