Ajax 使用 JSF 更新所有组件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6733709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 11:02:24  来源:igfitidea点击:

Ajax Update All components with JSF

ajaxjsf

提问by DD.

Is there a way to update all components or do I have to manually select each id? I have an ajax html5 detection script and dont want have to update every component via the id.

有没有办法更新所有组件,还是必须手动选择每个 ID?我有一个 ajax html5 检测脚本,不想通过 id 更新每个组件。

Thanks

谢谢

回答by BalusC

Just use the ID of the common parent component.

只需使用公共父组件的 ID。

<h:panelGroup id="someParent">
    <h:someComponentToUpdate ... />
    ...
    <h:someComponentToUpdate ... />
    ...
    <h:someComponentToUpdate ... />
    ...
</h:panelGroup>
...
<f:ajax render="someParent" />

Or use @allto refresh the entire page.

或用于@all刷新整个页面。

<f:ajax render="@all" />

回答by Thang Pham

If you need to invoke an update base on an event, I would recommend you use PrimeFaces. Check out their showcase at http://www.primefaces.org/showcase-labs/ui/home.jsf. Below show how to use update components when a button is click

如果您需要根据事件调用更新,我建议您使用 PrimeFaces。在http://www.primefaces.org/showcase-labs/ui/home.jsf 上查看他们的展示。下面显示了如何在单击按钮时使用更新组件

<p:commandButton value="Test" update="container" actionListener="#{myBean.process}"/>

Then have a wrapper container wrap around all components that you want to update like BalusC shows above.

然后让一个包装容器包裹您想要更新的所有组件,如上面的 BalusC 所示。

<h:panelGroup id="container">
     ...
     // All components you want to update here. 
</h:panelGroup>