Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind a boolean property to the rendered attribute?

Tags:

jsf

el

facelets

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?

like image 665
Krishna Avatar asked Dec 15 '11 15:12

Krishna


1 Answers

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;
}
like image 138
BalusC Avatar answered Oct 20 '22 07:10

BalusC