简体   繁体   English

使用PrimeFaces选择器更新非JSF组件的Ajax

[英]Ajax update of non-JSF component with PrimeFaces selectors

Is it possible to update any html fragment using Primefaces selectors - PFS? 是否可以使用Primefaces选择器更新任何html片段 - PFS? Consider this: 考虑一下:

<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. 这是一个例子 - 我真正的需要是更新数据表的某些部分,而不刷新整个组件。

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可以重新生成最终在ajax期间应用的所需HTML输出更新。

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. 如果为JSF提供纯HTML元素的ID,则它将不会在组件树中找到任何内容来重新生成所需的新HTML输出。 Just replace the plain HTML element by a JSF component. 只需用JSF组件替换纯HTML元素即可。

The PrimeFaces selectors get ultimately converted to HTML element IDs. PrimeFaces选择器最终转换为HTML元素ID。 PrimeFaces will loop over the elements found by the jQuery selector and extract their id attributes before passing to JSF. PrimeFaces将循环遍历jQuery选择器找到的元素,并在传递给JSF之前提取它们的id属性。 This is thus essentially the same problem as already answered here: Is it possible to update non-JSF components (plain HTML) with JSF ajax? 因此,这与本文已经回答的问题基本相同: 是否可以使用JSF ajax更新非JSF组件(纯HTML)? .

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

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