JSP check box usage

Source: Internet
Author: User

1. On the page CopyCode The Code is as follows: <TD width = "4%" Height = "26" align = "center">
<Input type = "checkbox" name = "checkbox"
Value = <% = user. GETID () %>/>
</TD>

2. Action Copy code The 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! ";
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.