Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces : update dialog content and keep it open

I'm working with JSF and PrimeFaces, and I can't handle the following situation: I have a dialog, and I placed a dataTable on it. In one of the cells of the table I would like to display given data in 3 different ways, and I'd like to switch between them. So far I managed to switch between these rendering types via commandLink, but my problem is that when I click on one of the 3 links, the dialog closes! Can I update the content of the dialog, and be able to keep it open the same time? (I'm updating which render type to use via myMethod)

my commandLink looks like this:

<p:commandLink id="id" update=":myForm:myDialog" ajax="false"
               action="#{myBean.myMethod}" oncomplete="dialog.show()">

If i don't use the ajax=false attribute, the method is not called, and I also tried imediate=true, but that's not it either.

like image 403
bajla Avatar asked Oct 29 '25 06:10

bajla


1 Answers

You need to define an p:outputPanel inside your dialog and update the outputpanel, not the dialog itself (that's why your dialog closes):

<p:dialog id="myDialog" ...>
  <p:outputPanel id="myOutputPanel">
    ... your dialog content goes here
  </p>
</p:dialog>

and change your commandlink

<p:commandLink id="id" update=":myForm:myDialog:myOutputPanel" ajax="true"
           action="#{myBean.myMethod}" oncomplete="dialog.show()">

Regarding the oncomplete="dialog.show()" - I'm not entirely sure if you need that. A precise answer can be given if you provide more code regarding your table and code.

like image 65
Manuel Avatar answered Nov 01 '25 14:11

Manuel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!