1 Introduction
Functional Requirements:
1 Select User interface to display in popup box
2 page Options Dynamic loading (department and user)
3 Save the checked user
Implementation analysis:
Save the selected user logic:
- Delete the previously selected list of user records (equivalent to vacuuming)
- Add a new Select User record list
Page
1 saving shared files
Save shared file function ShareFile () {//parameter var Signid = chooseobj.id; var objtype = Chooseobj.type; var userlist = ""; $ ("Input[name=shareuserid]"). each (function () {//This is the checkbox object in that HTML.So through//this.checked direct access to properties are all capable of if ($ (this). attr (' checked ')) {userlist = UserList +$ (This). Val () + ","}}); if (userlist.length>0) {userlist = userlist.substring (0, Userlist.length-1)} $.ajax ({ URL: '.. /share/sharefile.do ',//url: ' ${ctx}/index.jsp ', Cache:false, type: ' Post ', DataType: ' HTML ', Async:false, ContentType: "Application/x-www-form-urlencoded;charset=utf-8", Data: {' Signid ': Signid, ' objtype ': objtype, ' userlist ': Userlis T}, Success:function (ret) {//exception handling if (ret==3) { Handlewarm ("target folder is itself"); Return }else if (ret==2) {handlewarm ("cannot be moved to sub-folder"); Return }//CloseflowconTent (' Fxcontentflow '); Refreshthiscontent (); } }) }
page Options content HTML references (for references only). No implementation required)
Div class= "Fxtitle" > Academy leaders </div> <ul class= "Fxxz" > <li><input type= "checkbox" Name= "Shareus Erid "value=" Xiaolin "> Shorin </li> <li><input type=" checkbox "Name=" Shareuserid "Valu E= "Wangshuotong" > Wang Shuo Tong </li> <li><input type= "checkbox" Name= "Shareuserid" value= "W Angshengyang "> Wang Shengyang </li> <li><input type=" checkbox "Name=" Shareuserid "value=" Qifeng "> Kailash & nbsp;</li> <li><input type= "checkbox" Name= "Shareuserid" value= "Tangyiwen" > Tang Jinwen </li> <li><input type= "checkbox" Name= "Shareuserid" value= "Zhanglisheng" > Zhang Lixiang </li> <li><input type= "checkbox" Name= "Shareuserid" value= "Zhengshao" > Zheng </li> </ul> <di V class= "Fxtitle" > Office </div> <ul class= "Fxxz" > <li><input type= "checkbox" Name= "Shareuser Id "value=" lujianping "; Lu Jianping </li> <li><input type= "checkbox" checked= "true" Name= "Shareuserid" value= "Guosh Unlan "> Guo Shunlan </li> <li><input type=" checkbox "Name=" Shareuserid "value=" fangying "> Cynthia </li> <li><input type= "checkbox" Name= "Shareuserid" value= "Jiaoxiaojun" > Gio Xiaojun </li> <li><input type= "checkbox" checked= "true" Name= "Shareuserid" value= "Songweilei" > Song Weilei </li > <li><input type= "checkbox" Name= "Shareuserid" value= "Zhangxinmin" > Xinmin </li> < Li><input type= "checkbox" checked= "true" Name= "Shareuserid" value= "lijing" > Li Jing </li> <li><input type= "checkbox" Name= "Shareuserid" value= "Wangkaiyu" > Wang Kaiyu </li> </ul>
Background Code Controller Layerpublic void ShareFile (httpservletrequest request,httpservletresponse response) {String Signid = Request.getparameter ("Sig Nid ") = = 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, directories * * @param signid directory ID/File IDs * @param objtype Action Object Type (1:file, 2:folder) * @param UserList Sharing User Scope * @return 0 means the operation failed/1 indicates successful operation * */public int shareFile (string Signid, String ObjType, String userlist, String sharer) { //delete shared record Filesharedao.deletefileshare (Signid, objtype); New 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.setshareuser (Users[i]); Wpfileshare.setsharetime (New Date ()); Filesharedao.savefileshare (Wpfileshare); } }
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Select User-Save the selected user