Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

primefaces dialog disappears after show up

I have a commandButton and a dialog. The problem is after the dialog box appears, it disappears(1-2 miliseconds later). Is there a problem with my commandbutton or its dialog issue?

<p:commandButton id="showDetailsButton"
     title="Details"
     onclick="details.show();"
     process="@this"
     update=":tabView:myForm:myDialogId"                                         
     icon="ui-icon-search">                          
</p:commandButton>


<p:dialog id="myDialogId"
      header="Details"
      widgetVar="details"
      resizable="false"
      height="600"
      width="450"                  
      >
//some stuff
</p:dialog>
like image 781
Turgut Dsfadfa Avatar asked May 22 '13 09:05

Turgut Dsfadfa


2 Answers

Changed onclick to oncomplete and now It's working perfectly.

<p:commandButton id="showDetailsButton"
 title="Details"
 oncomplete="details.show();"
 process="@this"
 update=":tabView:myForm:myDialogId"                                         
 icon="ui-icon-search">                          

like image 82
Turgut Dsfadfa Avatar answered Oct 12 '22 18:10

Turgut Dsfadfa


By default a <p:commandButton> is rendered as

<button type="submit" ....> ... </button>

EDIT: Iff you've disabled ajax behavior by specifying ajax=false, please read comments below.

and hence it will trigger a Post Back. So your page makes a POST request to server and refreshes.

Btw, you don't need a PrimeFaces commandButton here, simply use

<input type="button" onclick="details.show()" value="Details"/>
like image 35
Niks Avatar answered Oct 12 '22 17:10

Niks