Object o = BeanUtil.getEmptyObject(className);
Object primaryKey = BeanUtil.getPrimaryKeyValue(object);
String primaryKeyName = BeanUtil.getPrimaryKeyName(o.getClass());
BeanUtil.setFieldValue(o, primaryKeyName, primaryKey);
SysUser user = (SysUser)dp.get(o);
//将此项目中的角色去掉,然后加上从客户端传来的角色。
filterRoles(user,context, false);
String userIds = user.getRoleIds();
String userNames = user.getRoleNames();
SysUser newUser = (SysUser)BeanUtil.getObject(user, properties, errors);
String newIds = newUser.getRoleIds();
String newNames = newUser.getRoleNames();
if(GenericValidator.isBlankOrNull(newIds)) {
newUser.setRoleIds(userIds);
newUser.setRoleNames(userNames);
} else {
newUser.setRoleIds(newIds.substring(0,newIds.length()-1)+userIds);
if(GenericValidator.isBlankOrNull(userNames))
newUser.setRoleNames(newNames);
else
newUser.setRoleNames(newNames + "、"+userNames);
}
dp.update(newUser);
request.setAttribute(Globals.OBJECT, newUser);
returnMessage = "保存成功<message>";
}