1 Introduction
Functional Requirements:
1 Select the user interface to display in a pop-up box
2 page Options dynamic loading (departments and users)
3 Save the Checked users
Implementation analysis:
Save selected user logic:
Deletes the list of user records that were originally selected (equivalent to empty operation)
Add a list of newly selected user records
Page
1 Save 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 the direct Access property via//This.checked is possible 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 ': userlist}, Success:function (ret) {//exception
Process if (ret==3) {handlewarm ("Destination folder is own");
Return
}else if (ret==2) {handlewarm ("Cannot move to subdirectory"); Return
}//Closeflowcontent (' Fxcontentflow ');
Refreshthiscontent ();
}
})
}
Page Options content HTML reference (for reference only, no implementation required)
<div class= "Fxtitle" > Institute leader </div> <ul class= "Fxxz" > <li><input type= "checkbox" Name= "Shareu Serid "value=" Xiaolin "> Shorin </li> <li><input type=" checkbox "Name=" Shareuserid "value=" Wangshuot Ong "> Wangshuo Tong </li> <li><input type=" checkbox "Name=" Shareuserid "value=" Wangshengyang "> Wang Shengyang < /li> <li><input type= "checkbox" Name= "Shareuserid" value= "Qifeng" > Kailash </li> <li><inpu T type= "checkbox" Name= "Shareuserid" value= "Tangyiwen" > Tang Jinwen </li> <li><input type= "checkbox" Name= "s Hareuserid "value=" Zhanglisheng "> Zhang Lixiang </li> <li><input type=" checkbox "Name=" Shareuserid "value = "Zhengshao" > Zheng </li> </ul> <div class= "fxtitle" > Office </div> <ul class= "Fxxz" > &L T;li><input type= "checkbox" Name= "Shareuserid" value= "lujianping" > Lu Jianping </li> <li><input type= "checkbox" checked= "true" nAme= "Shareuserid" value= "Guoshunlan" > Guo Shunlan </li> <li><input type= "checkbox" Name= "Shareuserid" V Alue= "fangying" > Fang Ying </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" > M.D. </li> <LI>&L T;input type= "checkbox" checked= "true" Name= "Shareuserid" value= "lijing" > Li jing </li> <li><input t
ype= "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, folders
* *
@param signid folder Id/file ID
* @param objtype Action Object Type (1:file, 2:folder)
* @param UserList Share User Scope
* @return 0 for operation failure/1 for Operation Success
* */public
int sharefile (string Signid, String ObjType, String userlist, String sharer) {
//delete shared records
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);
}