首页 > 解决方案 > 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;
}

我可能会犯这个错误。我想保存数据绑定到用户配置文件数据库的文档,但如果我提交它,我需要将它重定向到不同的页面。这就是我使用链接的原因,但是,我很难尝试保存文档。

标签: javaxpages

解决方案


在调用此代码之前已document1保存?如果不是,则它不在后端数据库中,无法通过getDocumentByID().

我假设这一行被错误地复制到这里,因为“noteID”不是一个 NoteID 或一个持有 NoteID 的变量,它是一个字符串。

doc = thisDB.getDocumentByID("noteID");


推荐阅读