Primefaces Selectors: How to exclude some componen

2019-08-15 02:59发布

问题:

I'm using a PrimeFaces commandButton to issue an Ajax request.
I should set the update attribute so that the whole parent form be updated EXCEPT for some specific components (Let's say I've tagged them with styleClass="noupdate").
I'm using PrimeFaces 3.5, so I think PrimeFaces JQuery Selectors may help.
I tried something like this:

<!-- ...some inputs/labels to be updated here... -->
<p:overlayPanel styleClass="noupdate">
    <!-- ...some inputs/labels to be updated here... -->
    <p:commandButton id="btnDoIt" value="Do it" 
            update="@(this.closest('form') :not(.noupdate))"/>  
</p:overlayPanel>

but it doesn't work (I get a JavaScript Syntax Error).
Is there a way to get what I need?
Notice that:
1) The form id is not known because the button is part of a composite component that can be hosted by any form in different views
2) In my example the <p:overlayPanel> itself must not be updated, but any descendant component do.
3) There are more than one form in the view, and I should work on the "current" one only.

Thank you in advance to anyone can help me.

回答1:

There's no such thing as this in PrimeFaces selectors. There are definitely no jQuery functions like $.closest() available in PrimeFaces selectors. It has just to be a pure jQuery-compatible CSS selector, not some JavaScript code.

<p:commandButton ... update="@(form :not(.noupdate))"/>

See also:

  • How to exclude child component in ajax update of a parent component?