我想通过触发我的 xpage 上的按钮单击事件来测试 java 代理以清除视图中的所有文档。我在 java 代理中没有错误,但它不工作。你能帮我度过这个阶段吗?
按钮点击事件:
var serverName=session.getCurrentDatabase().getServer();
//@WarningMessage("current one");
//@WarningMessage("server=" + serverName);
//var db:NotesDatabase = session.getDatabase(session.getCurrentDatabase().getServer(), "\ProTexII.nsf");
var db:NotesDatabase=session.getCurrentDatabase();
@WarningMessage("db=" + db);
var agent:NotesAgent = db.getAgent("SnapShotUpdate");
@WarningMessage("agent" + agent);
if (agent!=null){
agent.run();
@WarningMessage("view is fired!");
}
Java 代理:
package javaPkg;
import java.io.PrintWriter;
import lotus.domino.*;
public class SnapShotUpdate extends AgentBase{
public void NotesMain() {
try {
//String p = session.getPlatform();
//PrintWriter out=getAgentOutput();
System.out.println("Hello i never give it up!!");
Session session = getSession();
AgentContext agentContext =session.getAgentContext();
Database db=session.getCurrentDatabase();
//**clear view "vActualSalesFromSD" before copying documents into it
DocumentCollection dc= db.createDocumentCollection();
View view= db.getView("vActualSalesFromSD");
Document docToBeCleared= view.getFirstDocument();
while (docToBeCleared != null) {
{
dc.addDocument(docToBeCleared);
}
docToBeCleared = view.getNextDocument(docToBeCleared);
}
dc.removeAll(true);
} catch(Exception e) {
e.printStackTrace();
}
}
}