JSP check box using method _jsp programming

Source: Internet
Author: User
1, on the page
Copy Code code as follows:

<TD width= "4%" height= "align=" "Center" >
<input type= "checkbox" Name= "checkbox"
Value=<%=user.getid ()%>/>
</td>


2.action
Copy Code code as follows:

string[] checkbox = request.getparametervalues ("checkbox");
list<integer> Checkboxs = new arraylist<integer> ();
int Operatorid =sessionmgr.getaccountsession (request, Response). GetId ();
Logger.debug ("--operatorid--:" +operatorid);
Determine if the check box has a selection
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);
Judge whether it is oneself
if (Id==operatorid) {
Message= "Can not delete their own users";
}
Determine if admin super admin
if (id==1) {
Message= "Admin user cannot delete";
}
Determine if the user has a work list
Boolean isexist= false;
Isexist = Usermgr.isexistworkbillofuser (ID);
Logger.debug ("--isexist--:" +isexist);
if (isexist) {
Message = "The user has the construction bill can not be deleted";
}
if (id!=operatorid&&id!=1&&!isexist) {
Checkboxs.add (ID);
}
}
try{
Usermgr.deleteuser (CHECKBOXS);
message = "Delete Successful!" ";
}catch (SystemException se) {
Logger.error (SE);
}
}
else{
Message = "You haven't selected a user yet!" ";
}
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.