我在我的代码中使用PrimeFaces <p:ajax>
标记。我们如何排除子组件在更新父组件的ajax调用中更新?
如果您至少使用PrimeFaces 3.3,那么您可以使用PrimeFaces Selectors。这允许您在PrimeFaces ajax组件的jQuery CSS selector syntax和process
属性中使用update
。
例如:
<h:form>
<h:inputText ... />
<h:inputText ... />
<h:inputText ... styleClass="noupdate" />
<h:inputText ... />
<h:inputText ... />
<p:commandButton ... update="@(form :not(.noupdate))"/>
</h:form>
此示例将更新整个表单,但客户端中具有class="noupdate"
的输入除外。
如果要更新除某个组件之外的某个组件的所有子组件,请将“格式”替换为周围组件的ID(或类或...)
<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。