if (cb.isChecked() == true) {
// Get the group object by casting
SecGroup aGroup = (SecGroup) listitem.getAttribute("data");
// get the role
SecRole aRole = getSelectedRole();
// check if the item is newly checked. If so we cannot found
// it in the SecGroupRight-table
SecRolegroup aRoleGroup = getSecurityService().getRolegroupByRoleAndGroup(aRole, aGroup);
// if new, we make a newly Object
if (aRoleGroup == null) {
aRoleGroup = getSecurityService().getNewSecRolegroup();
aRoleGroup.setSecGroup(aGroup);
aRoleGroup.setSecRole(aRole);
}
try {
// save to DB
getSecurityService().saveOrUpdate(aRoleGroup);
} catch (DataAccessException e) {
ZksampleMessageUtils.showErrorMessage(e.getMostSpecificCause().toString());
}
} else if (cb.isChecked() == false) {
// Get the group object by casting
SecGroup aGroup = (SecGroup) listitem.getAttribute("data");
// get the role
SecRole aRole = getSelectedRole();
// check if the item is newly unChecked. If so we must
// found it in the SecRolegroup-table
SecRolegroup aRoleGroup = getSecurityService().getRolegroupByRoleAndGroup(aRole, aGroup);