使用原始面孔选择器对非jsf组件进行Ajax更新

时间:2022-05-27 20:03:38

Is it possible to update any html fragment using Primefaces selectors - PFS? Consider this:

是否有可能更新任何html片段使用原始面孔选择器- PFS?考虑一下:

<h:outputText id="test" value="#{testBean.date}"/>
<span id="test2"><h:outputText value="#{testBean.date}"/></span>

<p:commandButton value="test" process="@none" update="@(#test)"/>
<p:commandButton value="test2" process="@none" update="@(#test2)"/>

Only first button is refreshing. It's trival example - my real need is to update some parts of datatable, without refreshing whole component.

只有第一个按钮让人耳目一新。这是一个trival示例——我的真正需要是更新一些datatable的部分,而不需要刷新整个组件。

1 个解决方案

#1


3  

No, that's not possible. The update target must not only in client side be obtainable in HTML DOM tree by document.getElementById(), but also in server side by UIViewRoot#findComponent(), so that JSF can regenerate the desired HTML output which ultimately get applied during the ajax update.

不,那是不可能的。更新目标不仅在客户端可以通过document.getElementById()在HTML DOM树中获取,而且在服务器端也可以通过UIViewRoot#findComponent()获取,这样JSF就可以重新生成所需的HTML输出,最终在ajax更新中应用。

If you supply JSF the ID of a plain HTML element, then it won't find anything in the component tree to regenerate the desired new HTML output for. Just replace the plain HTML element by a JSF component.

如果向JSF提供一个普通HTML元素的ID,那么它在组件树中找不到任何东西来重新生成所需的新HTML输出。只需用JSF组件替换普通的HTML元素。

The PrimeFaces selectors get ultimately converted to HTML element IDs. PrimeFaces will loop over the elements found by the jQuery selector and extract their id attributes before passing to JSF. This is thus essentially the same problem as already answered here: Is it possible to update non-JSF components (plain HTML) with JSF ajax?.

基本面的选择器最终被转换为HTML元素id。PrimeFaces将遍历jQuery选择器找到的元素,并在传递给JSF之前提取它们的id属性。因此,这本质上与这里已经回答的问题相同:是否可能使用JSF ajax更新非JSF组件(纯HTML) ?

#1


3  

No, that's not possible. The update target must not only in client side be obtainable in HTML DOM tree by document.getElementById(), but also in server side by UIViewRoot#findComponent(), so that JSF can regenerate the desired HTML output which ultimately get applied during the ajax update.

不,那是不可能的。更新目标不仅在客户端可以通过document.getElementById()在HTML DOM树中获取,而且在服务器端也可以通过UIViewRoot#findComponent()获取,这样JSF就可以重新生成所需的HTML输出,最终在ajax更新中应用。

If you supply JSF the ID of a plain HTML element, then it won't find anything in the component tree to regenerate the desired new HTML output for. Just replace the plain HTML element by a JSF component.

如果向JSF提供一个普通HTML元素的ID,那么它在组件树中找不到任何东西来重新生成所需的新HTML输出。只需用JSF组件替换普通的HTML元素。

The PrimeFaces selectors get ultimately converted to HTML element IDs. PrimeFaces will loop over the elements found by the jQuery selector and extract their id attributes before passing to JSF. This is thus essentially the same problem as already answered here: Is it possible to update non-JSF components (plain HTML) with JSF ajax?.

基本面的选择器最终被转换为HTML元素id。PrimeFaces将遍历jQuery选择器找到的元素,并在传递给JSF之前提取它们的id属性。因此,这本质上与这里已经回答的问题相同:是否可能使用JSF ajax更新非JSF组件(纯HTML) ?