Krishna
Krishna

Reputation: 363

How to bind a boolean property to the rendered attribute?

I am using a boolean property in a JSF managed bean and depending on its value I have to render a command link on the facelet. But the problem is that facelets is showing this error:

Property 'isPlayButtonEnabled' is not found on my backing bean

So I tested the code by changing the data type of the property from boolean to String. Then facelets didn't show any error. But the command link component didn't get rendered in the view. How is this caused and how can I solve it?

Upvotes: 5

Views: 15030

Answers (1)

BalusC
BalusC

Reputation: 1109532

Property 'isPlayButtonEnabled' is not found on my backing bean

Remove the is prefix in the EL expression. It's now looking for a isIsPlayButtonEnabled() method. This should do:

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

with

public boolean isPlayButtonEnabled() {
    return playButtonEnabled;
}

Upvotes: 15

Related Questions