bajla
bajla

Reputation: 173

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.

Upvotes: 4

Views: 12451

Answers (2)

akelec
akelec

Reputation: 4013

I had the same problem, and solution is to update a form instead of dialog. For example:

<p:dialog id="id_dialog" ...>
  <h:form id="id_form">
      ... content
  </h>
</p:dialog>

and commandLink:

<p:commandLink update=":id_form" process="@all" ...>

This worked for me!

Upvotes: 0

Manuel
Manuel

Reputation: 4238

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.

Upvotes: 8

Related Questions