I have great problems with selectBooleanCheckbox. I have tried this (I have copy/paste it from my another project where it worked well):
<h:selectBooleanCheckbox id="checkbox1"
styleClass="selectBooleanCheckbox" required="true"></h:selectBooleanCheckbox>
public String doButtonAction() {
Boolean checked = (Boolean)getCheckbox1().getValue();
}
The problem is that above code always returns null.
Then I also tried:
<h:selectBooleanCheckbox id="checkbox1" value="#{myForm.checked}"
styleClass="selectBooleanCheckbox" required="true"></h:selectBooleanCheckbox>
boolean checked = false;
public boolean getChecked() {
return checked;
}
public void setChecked(boolean c) {
checked = c;
}
public String doButtonAction() {
Boolean checked = (Boolean)getCheckbox1().getValue();
// or:
//Boolean checked = getChecked();
}
The problem with above code is that setChecked() method is never called so "checked" field is always false. Why?