为什么要“渲染" JSF 2.0?不刷新页面无法正常工作吗? [英] why JSF 2.0 "rendered" does not work without refreshing the page?

查看:103
本文介绍了为什么要“渲染" 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>

另请参见:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆