JSF的dataTable使用selectBooleanCheckbox

JSF









...





后台Bean

public class MyBean ...{
private Map selectedIds = new HashMap();
private List selectedDataList;
public String getSelectedItems() ...{
selectedDataList = new ArrayList();
for (MyData dataItem : dataList) ...{
//如果使用了分页的话这个判断不可少.
if(selectIds.get(dataItem.getId())==null)...{
continue;
}
if (selectedIds.get(dataItem.getId()).booleanValue()) ...{
selectedDataList.add(dataItem);
selectedIds.remove(dataItem.getId()); // 删掉已取的项.
}
}
// 这里加需要处理的代码, 比如批量删除或修改.
return "selected";
}
public Map getSelectedIds() ...{
return selectedIds;
}
public List getSelectedDataList() ...{
return selectedDataList;
}
}

你可能感兴趣的:(JSF的dataTable使用selectBooleanCheckbox)