Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 214
Pranjali Avatar asked Sep 27 '12 05:09

Pranjali


1 Answers

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?
like image 103
BalusC Avatar answered Nov 09 '22 20:11

BalusC