コード例 #1
0
 // Listeners
 // ---------------------------------------------------------------
 public void fetchAssociatedRoleGroups(ActionEvent e) {
   User selectedUser = (User) dataTable.getRowData();
   Collection<UserRole> userRoles = selectedUser.getUserRoles();
   List<String> roleNames = new ArrayList<String>();
   for (UserRole r : userRoles) {
     roleNames.add(r.getRole() + "|" + r.getRoleGroup());
   }
   setAssociatedRoleGroupRoleNames(roleNames);
   usersAssociatedRoleGroupEditable = true;
   editModeRows.put(dataTable.getRowIndex(), true);
 }
コード例 #2
0
 @Override
 public void actionDelete() {
   // Get selected items.
   List<User> deleteItems = new ArrayList<User>();
   String deletedItemsNames = "";
   for (int index = 0; index < dataList.size(); index++) {
     if (isSelectedRow(index)) {
       deleteItems.add(dataList.get(index));
     }
   }
   if (deleteItems.isEmpty()) {
     ToolSet.setErrorMessage("Select at least one item to delete.");
     return;
   }
   Collection<UserRole> roles;
   for (User deleteItem : deleteItems) {
     // Check if there are roles assoicated with the user, before delete
     // action.
     roles = deleteItem.getUserRoles();
     if (roles.isEmpty()) {
       try {
         userDAO.remove(deleteItem);
         deletedItemsNames = deletedItemsNames + "(" + deleteItem.getUsername() + ");<br>";
       } catch (Exception e) {
         ToolSet.setErrorMessage(e.getMessage() + " Cause: " + e.getCause());
         e.printStackTrace();
         return;
       }
     } else {
       String message = "Disassociate from role before delete!";
       ToolSet.setErrorMessage(message);
       return;
     }
   }
   if (deletedItemsNames.length() > 0)
     ToolSet.setErrorMessage("Deleted entries: <br>" + deletedItemsNames);
 }