xpages调用后台代理
2015-09-29 14:57
561 查看
前段时间做了一个类似门户添加系统的功能,大体框架是,后台有几十个文档(主文档),文档里有读者域(都包括管理员),还有与主文档对应的目录文档(只有名字和临时记录用户),用户在xpages页面上看不到任何文档,然后用户点击添加,可以随意添加系统(在文档的读者域中添加上用户的邮箱)。
因为用户没有操作文档的权限(因读者域中并没有用户),所以需要按钮执行后台的代理(本文使用LS代理,使用java代理也是一样的),具体操作如下。
1、在前台按钮的服务前端添加如下JavaScript代码:
//comboBox1是获得用户的选择
var comboBox1:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("域名字");
var a = comboBox1.getValue();
//根据用户的选择找到对应目录文档,在目录文档中的临时用户域中添加上当前用户
var view = database.getView("视图名字")
var doc:NotesDocument = view.getDocumentByKey(a);
if(doc!=null){
doc.computeWithForm(false,false);
doc.save();
//执行代理,将目录文档ID传到代理中
agent = database.getAgent("代理名字");
unid = doc.getNoteID();
agent.run(unid);
return;
}
2、然后在代理中创建一个LS代理,注意:代理的触发器必须是基于事件,操作菜单选择,目标是无。
Sub Initialize
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim sdoc As NotesDocument
Dim ag As NotesAgent
Dim noteid As string
Set db = ss.Currentdatabase
Set ag = ss.Currentagent
noteid = ag.Parameterdocid
Set doc = db.Getdocumentbyid(noteid)
If doc Is Nothing Then
Print"啊啊啊,没有找到目录文档啊"
Exit sub
End If
Dim notename As String
notename = doc.dbname(0)
Set view = db.Getview("ALL")
Set sdoc = view.Getdocumentbykey(notename)
If sdoc Is Nothing Then
Print"啊啊啊,没有找到配置文档啊"
Exit Sub
End If
Dim item As NotesItem
Set item = sdoc.GetFirstItem("docReader")
Dim temname As String
temname = doc.temname(0)
Call item.AppendToTextList(temname)
item.IsReaders=True
Call sdoc.Save( False, True )
End Sub
以上的代码仅仅是找到主文档,然后得到目录文档中的用户名添加到主文档的读者域中,这样就可以实现任何的用户添加都是执行的管理员的权限。
因为用户没有操作文档的权限(因读者域中并没有用户),所以需要按钮执行后台的代理(本文使用LS代理,使用java代理也是一样的),具体操作如下。
1、在前台按钮的服务前端添加如下JavaScript代码:
//comboBox1是获得用户的选择
var comboBox1:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("域名字");
var a = comboBox1.getValue();
//根据用户的选择找到对应目录文档,在目录文档中的临时用户域中添加上当前用户
var view = database.getView("视图名字")
var doc:NotesDocument = view.getDocumentByKey(a);
if(doc!=null){
doc.computeWithForm(false,false);
doc.save();
//执行代理,将目录文档ID传到代理中
agent = database.getAgent("代理名字");
unid = doc.getNoteID();
agent.run(unid);
return;
}
2、然后在代理中创建一个LS代理,注意:代理的触发器必须是基于事件,操作菜单选择,目标是无。
Sub Initialize
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim sdoc As NotesDocument
Dim ag As NotesAgent
Dim noteid As string
Set db = ss.Currentdatabase
Set ag = ss.Currentagent
noteid = ag.Parameterdocid
Set doc = db.Getdocumentbyid(noteid)
If doc Is Nothing Then
Print"啊啊啊,没有找到目录文档啊"
Exit sub
End If
Dim notename As String
notename = doc.dbname(0)
Set view = db.Getview("ALL")
Set sdoc = view.Getdocumentbykey(notename)
If sdoc Is Nothing Then
Print"啊啊啊,没有找到配置文档啊"
Exit Sub
End If
Dim item As NotesItem
Set item = sdoc.GetFirstItem("docReader")
Dim temname As String
temname = doc.temname(0)
Call item.AppendToTextList(temname)
item.IsReaders=True
Call sdoc.Save( False, True )
End Sub
以上的代码仅仅是找到主文档,然后得到目录文档中的用户名添加到主文档的读者域中,这样就可以实现任何的用户添加都是执行的管理员的权限。
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- Android学习笔记(二九):嵌入浏览器
- Android java 与 javascript互访(相互调用)的方法例子
- JavaScript演示排序算法
- javascript实现10进制转为N进制数
- 2019年开发人员应该学习的8个JavaScript框架
- HTML中的script标签研究
- 对一个分号引发的错误研究
- 异步流程控制:7 行代码学会 co 模块
- ES6 走马观花(ECMAScript2015 新特性)
- JavaScript拆分字符串时产生空字符的原因
- Canvas 在高清屏下绘制图片变模糊的解决方法
- IE8开发人员工具教程(二)
- 在flex中执行一个javascript方法的简单方式
- Flex结合JavaScript读取本地路径的方法
- PowerShell中执行Javascript的方法示例
- javascript asp教程第六课-- response方法
- javascript asp教程More About Recordsets
- javascript asp教程第十二课---session对象