Render multiple components with f:ajax

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 10:58:41

问题


The wrong codes are:

<h:form id="search_form">
<h:commandButton class="button" value="View" action="#{InfoBean.search}">
    <f:ajax execute="search_form" render="linear1"></f:ajax>
    <f:ajax execute="search_form" render="linear2"></f:ajax>
</h:commandButton>
<p:lineChart id="linear1" value="#{InfoBean.linearModel1}" legendPosition="e"/>
<p:lineChart id="linear2" value="#{InfoBean.linearModel2}" legendPosition="e"/>
</h:form>

What I want to do is when I click on the commandButton, I want to refresh those two charts. But now I used two <ajax> tags, of which the second doesn't work.

So how can I use ajax to render two charts?


回答1:


You can render multiple components with single f:ajax. Just make sure all individual components you want to update have an id. In your sample it would be something like:

<f:ajax execute="search_form" render="linear1 linear2"/>

Where the IDs need to be separated by just whitespace like linear1 linear2 and not commaseparated like linear1, linear2 (that works only in p:ajax).

See also:

  • Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes
  • How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"



回答2:


For a4j jsf use ',': <a4j:support event="onchange" reRender="parent,child1,child2" />



来源:https://stackoverflow.com/questions/16597542/render-multiple-components-with-fajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!