I want to bind <p:selectBooleanCheckbox> to my controller method. I am getting below error when I try to bind. Is there any other way?
Property 'calculateBooleanValue' not found on type tr.controller.MyController
Here is my view
<p:datatable var="dataRow" ....>
<p:selectBooleanCheckbox value="#{myController.calculateBooleanValue(dataRow)}" />
MyController
public boolean calculateBooleanValue(Data data) {
//There are some calculations with data and returns some boolean value acc. to this data
}
The value attribute must represent a value expression. I.e. it must be bound to a property which is represented by a true javabean getter and setter. You should not use method expression syntax with parentheses, this is not a valid value expression syntax.
Thus, so:
<p:selectBooleanCheckbox value="#{myController.booleanValue}" />
with
private boolean booleanValue;
@PostConstruct
public void init() {
booleanValue = true;
}
public boolean isBooleanValue() {
return booleanValue;
}
public void setBooleanValue(boolean booleanValue) {
this.booleanValue = booleanValue;
}
If you intend to execute some "controller method" (as you call it yourself) on every click of the checkbox, then add a <p:ajax> with a listener:
<p:selectBooleanCheckbox value="#{myController.booleanValue}">
<p:ajax listener="#{myController.changeBooleanValue}" />
</p:selectBooleanCheckbox>
with
public void changeBooleanValue() {
System.out.println("Current boolean value is: " + booleanValue);
// ...
// Do your job here.
}
You can't. value takes a Value Expression, not a Method Expression.
Think about it, how is the property going to be written, if it's a method?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With