java - NotesException:未提供必需的参数
问题描述
我的 XPage 收集信息,用于在不同的 Domino 数据库中填充文档。我使用链接按钮(这样我可以在提交后打开另一个 XPage)。onClick 代码如下:
var rtn = true
var util = new utilities()
var hostURL = configBean.getValue("HostURL");
var userAttachment;
//set up info needed for checking duplicates
var attachName=getComponent("attachmentIdentifier").getValue();
var serialNbr = getComponent("serialNumber").getValue();
userAttachment = user+"~"+attachName;
var userSerial = user+"~"+serialNbr;
//Done setting info needed
//check for duplicates
rtn = utilBean.checkAttachmentName(userAttachment, userSerial)
//done
if(rtn==true){
var doc:Document = document1;
dBar.info("ALL IS GOOD");
var noteID:String=document1.getNoteID();
dBar.info("Calling saveNewAttachment using NoteID " + noteID )
rtn=utilBean.saveNewAttachment(session,noteID ); //<<< I get error here
dBar.info("rtn = " + rtn)
return "xsp-success";
view.postScript("window.open('"+sessionScope.nextURL+"')")
}else if (rtn==false){
errMsgArray = utilBean.getErrorMessages();
for(err in errMsgArray){
//for (i=0; i < errMsgArray.size(); i++){
dBar.info("err: "+ err.toString());
if (err== "nameUsed"){
//send message to XPXage
facesContext.addMessage(attachmentIdentifier.getClientId(facesContext) , msg(langBean.getValue("duplicateName")));
}
if(err=="serialUsed"){
//send message to XPXage
facesContext.addMessage(serialNumber.getClientId(facesContext) , msg(langBean.getValue("duplicateSerial")));
}
}
return "xsp-failure";
}
传递错误的java代码是这个
public boolean saveNewAttachment(Session ses, String noteID)
throws NotesException {
debugMsg("Entering saveNewAttachment and NOTEID = "+noteID);
// this is used when the user saves an attachment to to the
// user profiles db
boolean rtn = false;
Document doc;
ConfigBean configBean = (ConfigBean)
ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(),
"configBean");
String dbName = (String) configBean.getValue("WebsiteDbPath");
debugMsg("A");
Database thisDB = ses.getDatabase(ses.getServerName(), dbName, false);
String value;
try {
debugMsg("noteID: "+noteID);
下一行抛出 NotesException 错误
doc = thisDB.getDocumentByID("noteID");
debugMsg("C");
} catch (Exception e) {
debugMsg("utilitiesBean.saveAttachment: " + e.toString());
e.printStackTrace();
System.out.println("utilitiesBean.saveAttachment: " + e.toString());
throw new RuntimeException("utilitiesBean.saveAttachment: "
+ e.toString());
}
return rtn;
}
我可能会犯这个错误。我想保存数据绑定到用户配置文件数据库的文档,但如果我提交它,我需要将它重定向到不同的页面。这就是我使用链接的原因,但是,我很难尝试保存文档。
解决方案
在调用此代码之前已document1
保存?如果不是,则它不在后端数据库中,无法通过getDocumentByID()
.
我假设这一行被错误地复制到这里,因为“noteID”不是一个 NoteID 或一个持有 NoteID 的变量,它是一个字符串。
doc = thisDB.getDocumentByID("noteID");
推荐阅读
- node.js - 使用 setTimeout 发送邮件
- reactjs - 子菜单项 Gatsby+WordPress 无头 CMS
- c# - 读取文本文件,将其拆分,然后在 listBox 中显示
- keras - 模块对象是笔记可调用,连体神经网络
- c# - Visual c++ 库
- javascript - 将 SVG 导入 paper.js 中的路径返回 null
- c# - 外部 CRM 收入电子邮件 CRM Dynamics 365
- powershell - 提取这行文本的有效方法
- java - 如何在Android应用程序中找到在两个地方之间旅行所需的时间
- hazelcast - 缩放和最小仲裁大小