Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

selectBooleanCheckbox

843844Aug 14 2008 — edited Aug 19 2008
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?

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 16 2008
Added on Aug 14 2008
10 comments
276 views