Reputation: 61
JSF, Java Server Faces, Primefaces.
I am struggling to find a solution on how to change the update attribute of a <p:ajax
Scenario: A Dialog with a <p:ajax to capture the close event
<p:dialog modal="true">
<p:ajax event="close" update="COMPONENT IDs"
listener="#{bean.onClose()}" />
I would like to change the update attribute when I open the dialog. I tried
using an EL expression value to get the changing attribute value from a bean. This does not work as the attribute value is set at first rendering and never again
Adding the update component IDs in the listener method of the bean:
PrimeFaces.current().ajax().update("component IDs");
This works. BUT: Not for PrimeFaces Selectors (PFS). And I need that.
Like update="@(.mystyle)"
(I guess because in that case components are selected client sidy by jquery.)
Any ideas? Thank you Peter
Upvotes: 3
Views: 51
Reputation: 12039
Peter,
There is an open ticket to allow dynamic update=""
which is an open Faces Specification question as well. See Faces Spec issue: https://github.com/jakartaee/faces/issues/1499
However have you considered the Observer pattern in PrimeFaces? https://www.primefaces.org/showcase/ui/ajax/observer.xhtml
Basically your dialog should just "fire an event" and your components should subscribe to that event. If any components are not rendered=""
they obviuously won't care about that event. So the dialog's job is just to fire an closeDialog
event and any components rendered on the page that care about that should subscribe?
Upvotes: 1