0

I am trying to open a dialog box in JSF using p:commandLink

<p:commandLink id="linkId" update="@this someDialogId" value="open dialog" action="#{someBean.someAction(id)}"/>

<p:dialog closable="true" id="someDialogId" closeOnEscape="true" maximizable="true" minimizable="true" fitViewport="true" modal="true" header="Task Details" rendered="#{someBean.displayDiag}" visible="#{someBean.displayDiag}" >

    // Something displayed
</p:dialog>

But nothing happens when I click over the p:commandLink ?

This p:commandLink and p:dialog are located in different div's inside the same form.

John
  • 276
  • 1
  • 9
  • 29
  • 3
    See https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes – Jasper de Vries Jun 04 '20 at 12:17
  • I read it and tried using p:ajax update="@this id" or f:ajax execute="Id" but none seem to work, what is happening is when I click link to to dialog box nothing happens and when some other item is clicked then dialog box enters. – John Jun 07 '20 at 06:00
  • @JasperdeVries My whole application is suffering from this refreshing issue, it will be great help if you can pin point how to stop refreshing whole form when dialog box opens. – John Jun 07 '20 at 06:01

1 Answers1

1

Have a look at the PrimeFaces showcase: https://www.primefaces.org/showcase/ui/overlay/dialog/basic.xhtml

You update the dialog but you do not open it.

First of all your dialog needs a widgetVar property. Let’s say it's "myDialog".

Then in your commandLink you add a java script handler for oncomplete. There you open the dialog.

Like <p:commandLink ... oncomplete="PF('myDialog').show()" ... />

TomStroemer
  • 1,390
  • 8
  • 28