简体   繁体   English

JSF PrimeFaces Ajax更新,不包含一个组件

[英]JSF PrimeFaces ajax update excluding one component

I got a form, that includes outputPanel that I need to update, excluding one of its component (it containts calendar, that resets after I call update , I want to prevent that) 我得到了一个包含我需要更新的outputPanel的表单,但不包含其组件之一(它包含日历,该日历在我调用update之后重置,我想防止这种情况)

<p:ajax update=":form1:outputPanel1 :not(form1:outputPanel1:nestedOutputPanel)"/>

But I have no idea how can I achieve something like this (above example is not working)? 但是我不知道如何实现这样的功能(上面的示例不起作用)?

The PrimeFaces update attribute takes one or more expressions separated by a space (or comma). PrimeFaces update属性采用一个或多个用空格(或逗号)分隔的表达式。 Normally (in plain JSF) those expressions are client IDs, but in PrimeFaces you can also use selectors . 通常(在纯JSF中)这些表达式是客户端ID,但在PrimeFaces中,您也可以使用选择器 A selector is executed and results in a list of client IDs to update. 执行选择器,并生成要更新的客户端ID列表。 You could use a selector to select all the components that need to be updated and exclude the component you don't want to update. 您可以使用选择器来选择所有需要更新的组件,并排除您不想更新的组件。

You could add a style class to the component you want to exclude and use something like: 您可以将样式类添加到要排除的组件中,并使用类似以下内容的方法:

update="@(.parent :not(.exclude))"

As you can read in the top answer on the linked question, the @(...) selector will be used as a jQuery selector. 正如您在链接的问题的顶部答案中可以看到的那样, @(...)选择器将用作jQuery选择器。 So you can easily test selectors in your browser's JavaScript console as $("...") . 因此,您可以轻松地在浏览器的JavaScript控制台中将选择器测试为$("...")

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM