首页 / 软件开发 / JAVA / 用JSF实现页面刷新后,checkbox仍处于选中状态
用JSF实现页面刷新后,checkbox仍处于选中状态2011-01-04 javaeye icyheart这个功能要是用JS实现是有些麻烦的,用JSF把前台与后台bean进行绑定就可轻松实现。页面代码:Java代码<h:selectBooleanCheckbox value="#{recu_planBB.selectAll}" onclick="return displayAll();"/>Js代码function displayAll(){
document.form1.action="/recruit/planAudit.jsf";
document.form1.submit();
return true;
}后台bean代码:Java代码private boolean selectAll;
public boolean getSelectAll() {
return selectAll;
}
public void setSelectAll(boolean selectAll) {
this.selectAll = selectAll;
}在checkbox没有选中的情况下,默认的值为false,选中后即可变成true,这样以来,只要你选中了checkbox它就会一直处于选中状态,除非你把它去掉。