6
votes

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>
3
Please read @BalusC's comments on my answer. You need to provide more details in the question!Niks

3 Answers

8
votes

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">                          

3
votes

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"/>
0
votes

remove the process and update from your commandbutton. They refresh the page/section. And you don't want that.