【问题标题】:The rerendered attribute not working on a4j:commandButton [duplicate]重新渲染的属性不适用于 a4j:commandButton [重复]
【发布时间】:2015-11-05 04:05:17
【问题描述】:

我在我的项目中使用 JSF 1.2 和 RichFaces。我正在尝试实现如下场景,我的页面中有两个rich:panel,它们的渲染属性设置为bean中的boolean变量,并且该变量的默认值设置为false,所以第一次加载页面时,面板不会被渲染。我的页面中有一个a4j:commandButton,并且在按钮的操作属性上我在我的bean中调用了一个方法,该方法设置了两个标志变量,但是即使在设置了变量之后面板也没有呈现,我也在设置按钮的rerendered 属性,我认为我没有遗漏任何步骤。

【问题讨论】:

    标签: jsf richfaces jsf-1.2


    【解决方案1】:

    如果在页面加载时组件没有被渲染,那么即使您在某些命令按钮单击时将布尔变量的值更改为 true,它也不会进行任何更改。您的组件应该可以在 Button click 上呈现。所以把你的组件放在另一个组件里面请检查下面的代码

    #{bean.renderResult} 默认为 false 时,以下将不起作用:

    <h:form id="form">
        <h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
            <f:ajax render=":result" />
        </h:commandButton>
    </h:form>
    <h:outputText id="result" value="#{bean.result}" rendered="#{bean.renderResult}" />
    

    您需要确保呈现 ID 指向的组件已经存在于 JSF 生成的 HTML 输出中。

    以下将起作用:

    <h:form id="form">
        <h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
            <f:ajax render=":result" />
        </h:commandButton>
    </h:form>
    <h:panelGroup id="result">
        <h:outputText value="#{bean.result}" rendered="#{bean.renderResult}" />
    </h:panelGroup>
    

    更多信息请查看http://balusc.blogspot.in/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichIsByItselfConditionallyRendered

    【讨论】:

    • 如果您知道 Q 是关于“基本”jsf 概念/问题/警告/...,请先搜索重复项
    • 好的,谢谢您的信息
    猜你喜欢
    • 2012-11-26
    • 2015-04-28
    • 2021-10-04
    • 2021-09-04
    • 2021-03-24
    • 1970-01-01
    相关资源
    最近更新 更多