Jquery implements saving selected users, while jquery implements users
1 Introduction
Functional requirements:
1. Select the user interface and display it in a pop-up box.
2. Dynamic Loading of page options (department and user)
3. Save the selected user
Implementation Analysis:
Save the selected user logic:
Delete the previously selected user record list (equivalent to clearing)
Add a list of newly selected user records
Page
1. Save shared files
// Save the shared file function using file () {// parameter var signid = chooseObj. id; var objtype = chooseObj. type; var userlist = ""; $ ("input [name = Your userid]"). each (function () {// this is the checkbox object in the html. So through // this. if ($ (this ). attr ('checked') {userlist = userlist + $ (this ). val () + ","}); if (userlist. length> 0) {userlist = userlist. substring (0, userlist. length-1)} $. ajax ({url :'.. /share/upload file. do ', // url:' $ {ctx}/index. jsp ', cache: false, type: 'post', ype: 'html', async: false, contentType: "application/x-www-form-urlencoded; charset = UTF-8 ", data: {'signid': signid, 'objtype': objtype, 'userlist': userlist}, success: function (ret) {// Exception Handling if (ret = 3) {handleWarm ("the target folder is your own"); return;} else if (ret = 2) {handleWarm ("sub-directories cannot be moved"); return ;}// closeflowcontent ('fxcontentflow'); refreshThisContent ();}})}
Html reference of page option content (for reference only, no need to implement)
<Div class = "fxtitle"> school leader </div> <ul class = "fxxz"> <li> <input type = "checkbox" name = "shareUserId" value = "xiaolin "> Xiao Lin </li> <input type =" checkbox "name =" shareUserId "value =" wangshuotong "> Wang Shuo </li> <input type = "checkbox" name = "shareUserId" value = "wangshengyang"> Wang shengyang </li> <input type = "checkbox" name = "shareUserId" value = "qifeng "> Qi Feng </li> <input type =" checkbox "name =" shareUserId "value =" tangyiwen "> Tang Yiwen </li> <input type = "checkbox" name = "shareUserId" value = "zhanglisheng"> Zhang Lisheng </li> <input type = "checkbox" name = "shareUserId" value = "zhengshao "> Zheng </li> </ul> <div class =" fxtitle "> Office </div> <ul class =" fxxz "> <li> <input type = "checkbox" name = "shareUserId" value = "lujianping"> Lu Jianping </li> <input type = "checkbox" checked = "true" name = "shareUserId" value = "guoshunlan"> Guo shunlan </li> <input type = "checkbox" name = "shareUserId" value = "fangying"> Fang Ying </li> <li> <input type = "checkbox" name = "shareUserId" value = "jiaoxiaojun"> Jiao Xiaojun </li> <input type = "checkbox" checked = "true" name = "Your userid" value = "songweilei"> song weilei </li> <input type = "checkbox" name = "Your userid" value = "zhangxinmin"> Zhang Xinmin </li> <input type = "checkbox" checked = "true" name = "shareUserId" value = "lijing"> li Jing </li> <input type = "checkbox" name = "shareUserId" value = "wangkaiyu"> Wang Kaiyu </li> </ul>
Background code
Controller Layer
public void shareFile(HttpServletRequest request,HttpServletResponse response) { String signid = request.getParameter("signid") == null? "": request.getParameter("signid"); String objtype = request.getParameter("objtype") == null? "": request.getParameter("objtype"); String userlist = request.getParameter("userlist") == null?"": request.getParameter("userlist"); User user = (User)request.getSession().getAttribute("user"); int result = fileShareManager.shareFile(signid, objtype, userlist, user.getUserid().getValue()); try{ request.setCharacterEncoding("UTF-8"); PrintWriter pw = response.getWriter(); pw.write("" + result); pw.flush(); pw.close(); }catch (Exception e) { // TODO: handle exception e.printStackTrace(); } }
Service Layer
/*** Specify shared files and folders ** @ param signid folder id/file id * @ param objtype operation object type (1: file, 2: folder) * @ param userlist shared user range * @ return 0 indicates operation failed/1 indicates operation succeeded **/public int shareFile (String signid, String objtype, String userlist, String sharer) {// Delete the shared record fileShareDao. deleteFileshare (signid, objtype); // create a shared record String users [] = userlist. split (","); // save each shared user for (int I = 0; I <users. length &&! Users [0]. equals (""); I ++) {WpFileshare wpFileshare = new WpFileshare (); wpFileshare. setSharer (sharer); wpFileshare. setincluuser (users [I]); wpFileshare. setSharetime (new Date (); fileShareDao. saveFileshare (wpFileshare );}}
How to Implement fixed regions in js, java, jquery, and jsp and pop up the Save box
When you use java commands to execute class files, there is no suffix.
If there is an App. class
Enter
Java App
How can I save the status of a local html file after jquery operation?
It can be saved using cookies. Cookies exist locally, so no background is required.
Jquery has a cookie plug-in. Please find it by lz.