1. On the page
Copy codeThe Code is as follows:
<Td width = "4%" height = "26" align = "center">
<Input type = "checkbox" name = "checkbox"
Value = <% = user. getId () %>/>
</Td>
2. action
Copy codeThe Code is as follows:
String [] checkbox = request. getParameterValues ("checkbox ");
List <Integer> checkboxs = new ArrayList <Integer> ();
Int operatorId = SessionMgr. getAccountSession (request, response). getId ();
Logger. debug ("-- operatorId --:" + operatorId );
// Check whether the check box is selected
If (checkbox! = Null &&! "". Equals (checkbox )){
For (int I = 0; I <checkbox. length; I ++ ){
// Checkboxs. add (checkbox [I]);
String id_str = checkbox [I];
Int id = Integer. parseInt (id_str );
// Determine whether it is your own
If (id = operatorId ){
Message = "users cannot be deleted ";
}
// Determine if it is an admin super Administrator
If (id = 1 ){
Message = "admin users cannot delete ";
}
// Determine whether the user has a ticket
Boolean isExist = false;
IsExist = UserMgr. isExistWorkbillOfUser (id );
Logger. debug ("-- isExist --:" + isExist );
If (isExist ){
Message = "this user cannot delete a ticket ";
}
If (id! = OperatorId & id! = 1 &&! IsExist ){
Checkboxs. add (id );
}
}
Try {
UserMgr. deleteUser (checkboxs );
Message = "deleted successfully! ";
} Catch (SystemException se ){
Logger. error (se );
}
}
Else {
Message = "You have not selected a user! ";
}