【问题标题】:How to bind a boolean property to the rendered attribute?如何将布尔属性绑定到呈现的属性?
【发布时间】:2012-01-21 06:52:40
【问题描述】:

我在 JSF 托管 bean 中使用 boolean 属性,根据它的值,我必须在 facelet 上呈现命令链接。但问题是 facelets 显示这个错误:

在我的支持 bean 上找不到属性“isPlayButtonEnabled”

所以我通过将属性的数据类型从boolean 更改为String 来测试代码。然后facelets没有显示任何错误。但是命令链接组件没有在视图中呈现。这是如何引起的,我该如何解决?

【问题讨论】:

  • 请贴一些代码(属性、getter&setter、使用属性的部分视图)。

标签: jsf facelets el


【解决方案1】:

在我的支持 bean 上找不到属性“isPlayButtonEnabled”

删除 EL 表达式中的 is 前缀。它现在正在寻找isIsPlayButtonEnabled() 方法。应该这样做:

<h:commandButton rendered="#{bean.playButtonEnabled}" />

与

public boolean isPlayButtonEnabled() {
    return playButtonEnabled;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 2016-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多