Primefaces Selectors: How to exclude some components when updating the closest form?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 09:05:25

问题


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?


来源:https://stackoverflow.com/questions/15790160/primefaces-selectors-how-to-exclude-some-components-when-updating-the-closest-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!