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

后端 未结 1 1474
南方客
南方客 2020-11-27 05:54

I am using PrimeFaces tag in my code. How we can exclude a child component from getting updated in an ajax call that update a parent component?

相关标签:
1条回答
  • 2020-11-27 06:22

    If you're using at least PrimeFaces 3.3, then you can use PrimeFaces Selectors for this. This allows you using jQuery CSS selector syntax in process and update attributes of PrimeFaces ajax components.

    For example:

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

    This example will update the entire form except for inputs having class="noupdate" in the client side.

    If you want to update a all children of a certain component except one, replace 'form' by the id of the surrounding component (or a class or...)

    <h:form id="form">
        <h:panel id="myPanel">
            <h:inputText ... />
            <h:inputText ... />
            <h:inputText ... styleClass="noupdate" />
        </h:panel>
        <h:inputText ... />
        <h:inputText ... />
        <p:commandButton ... update="@(form :not(.noupdate))"/>
    </h:form>
    
    <p:commandButton ... update="@(#form\:myPanel :not(.noupdate))"/>
    

    Just make sure you use the full client-side id.

    See also:

    • How do PrimeFaces Selectors as in update="@(.myClass)" work?
    0 讨论(0)
提交回复
热议问题