如何在父组件的ajax更新中排除子组件? [英] How to exclude child component in ajax update of a parent component?

查看:23
本文介绍了如何在父组件的ajax更新中排除子组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的代码中使用 PrimeFaces 标签.我们如何在更新父组件的 ajax 调用中排除子组件的更新?

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?

推荐答案

如果你至少使用 PrimeFaces 3.3,那么你可以使用 PrimeFaces 选择器.这允许您在 process 中使用 jQuery CSS 选择器语法>更新 PrimeFaces ajax 组件的属性.

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.

例如:

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

此示例将更新整个表单,除了客户端中具有 class="noupdate" 的输入.

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

如果你想更新某个组件的所有子组件,除了一个组件,用周围组件(或类或...)的 id 替换 'form'

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))"/>

只需确保使用完整的客户端 ID.

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

这篇关于如何在父组件的ajax更新中排除子组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆