为什么要“渲染" JSF 2.0?不刷新页面无法正常工作吗? [英] why JSF 2.0 "rendered" does not work without refreshing the page?
本文介绍了为什么要“渲染" JSF 2.0?不刷新页面无法正常工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我单击一种方法来渲染页面的一部分时,除非手动刷新页面,否则它不会更改任何内容.
When I click a method to render a part of the page, it does not change anything until I manually refresh the page.
这是豆子:
boolean showPage = true;
public boolean getShowPage(){
return showPage;
}
这是视图:
<h:form>
<p:commandButton value="Click" action="#{bean.hideContents()}" />
</h:form>
<p:panel rendered="#{bean.showPage}">
Contents
</p:panel>
当我手动刷新页面时,该面板将隐藏,否则不会隐藏. 这是怎么引起的,我该如何解决?
The panel gets hidden when I manually refresh the page, otherwise it does not. How is this caused and how can I solve it?
推荐答案
您需要更新条件渲染组件的父组件.您可以通过在<p:commandButton>
的update
属性中指定其客户端ID来做到这一点:
You need to update a parent component of the conditionally rendered component. You can do that by specifying its client ID in the update
attribute of the <p:commandButton>
:
<h:form>
<p:commandButton value="Click" action="#{bean.hideContents}" update=":panel" />
</h:form>
<h:panelGroup id="panel">
<p:panel rendered="#{bean.showPage}">
Contents
</p:panel>
</h:panelGroup>
另请参见:
- 如何查找客户端用于ajax更新/渲染的组件的ID?找不到表达式为"foo"的组件;引用自"bar"
- 为什么我需要嵌套带有render ==#{some}"的组件?在另一个组件中,当我想对其进行ajax更新时?
- How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"
- Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?
See also:
这篇关于为什么要“渲染" JSF 2.0?不刷新页面无法正常工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文