getItemValueInteger异常消息

时间:2019-03-20 12:37:22

标签: xpages xpages-ssjs

OpenLogger给我以下错误:

  

表达语言解释异常错误:方法   找不到NotesXspDocument.getItemValueInteger(number),或者是非法的   参数-chkReview出错:

     

解释异常

     

错误:找不到方法NotesXspDocument.getItemValueInteger(number),   或非法参数

组件chkReview只有两行使用了getItemValueInteger,它位于onClick事件(单个复选框)上:

var reviewField:string = "numberOfReviewQuestions"+compositeData.reviewTeam;
var currentNumberReview = document1.getItemValueInteger(reviewField);   
var sectionReview:string = compositeData.section + compositeData.reviewTeam;    
var currentNumberSection = document1.getItemValueInteger(sectionReview);

compositeData.reviewTeam和CompositeData.section都返回一个字符串。因此,我不确定是否具有隧道视觉,但是我看不到代码有什么问题?谁能指出正确的方向?如果有帮助,请在下面进行堆栈跟踪,同时还要提供完整的onClick代码,谢谢:

try{
    var strCurrVal = getComponent('txtReviewSummary').getValue();
    var strNewVal ="";
    var strText ="";
    var dt = new Date();
    var strUser = userBean.getDisplayName();
    var reviewField:string = "numberOfReviewQuestions"+compositeData.reviewTeam;
    var currentNumberReview = document1.getItemValueInteger(reviewField);   
    var sectionReview:string = compositeData.section + compositeData.reviewTeam;    
    var currentNumberSection = document1.getItemValueInteger(sectionReview);

if (getComponent('chkReview').getValue() == "true") {
    // checkbox selected - do something
    var dateTimeFormat = new java.text.SimpleDateFormat("dd/MM/yyyy kk:mm");
    var dateTimeString = dateTimeFormat.format(dt);
    var strReview = " - [Review] - ("+dateTimeString+" - " + strUser + ")";
    strNewVal = strCurrVal+strReview;
    strText = "Review complete for " + compositeData.fieldName;
    document1.replaceItemValue(reviewField, currentNumberReview-1); 
} else {
    // checkbox not selected- do something else
    strNewVal = @Left(strCurrVal, " - [Review]");
    strText = "Removed review for " + compositeData.fieldName + ". Previous value was: " + strNewVal;
    document1.replaceItemValue(reviewField, currentNumberReview+1); 
}

var arrNotes:array = AddNoteItem(currentDocument, dt, strText, strUser);
document1.replaceItemValue(concatReviewSummary, strNewVal);
document1.save();

}catch(e){
    openLogBean.addError(e,this.getParent());
}


> com.ibm.jscript.InterpretException: Interpret exception at
> com.paulwithers.openLog.OpenLogErrorHolder.getInterpretException(OpenLogErrorHolder.java:114)
> at
> com.paulwithers.openLog.OpenLogErrorHolder.addError(OpenLogErrorHolder.java:216)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
> at java.lang.reflect.Method.invoke(Method.java:508) at
> com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:322)
> at com.ibm.jscript.types.FBSObject.call(FBSObject.java:161) at
> com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197) at
> com.ibm.jscript.ASTTree.ASTTry.interpretCatch(ASTTry.java:150) at
> com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:113) at
> com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119) at
> com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139) at
> com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
> at com.ibm.jscript.JSExpression.access$1(JSExpression.java:424) at
> com.ibm.jscript.JSExpression$2.run(JSExpression.java:414) at
> java.security.AccessController.doPrivileged(AccessController.java:730)
> at
> com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
> at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
> at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
> at
> com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222)
> at
> com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
> at
> com.ibm.xsp.application.ActionListenerImpl.processAction(ActionListenerImpl.java:60)
> at javax.faces.component.UICommand.broadcast(UICommand.java:324) at
> com.ibm.xsp.component.UIEventHandler.broadcast(UIEventHandler.java:366)
> at
> com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
> at
> com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
> at
> com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
> at
> com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
> at
> com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
> at
> com.ibm.xsp.component.UIViewRootEx.broadcast(UIViewRootEx.java:1535)
> at
> javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:307)
> at
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:428)
> at
> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:94)
> at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
> at
> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
> at
> com.ibm.xsp.controller.FacesControllerImpl.execute(FacesControllerImpl.java:256)
> at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:227)
> at
> com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
> at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:159) at
> com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138) at
> com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
> at
> com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:588)
> at
> com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)
> at
> com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:865)
> at
> com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:808)
> at
> com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:577)
> at
> com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)
> at
> com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
> at
> com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
> at
> com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)
> at
> com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
> at
> com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
> Caused by: java.lang.Throwable: Error:Method
> NotesXspDocument.getItemValueInteger(number) not found, or illegal
> parameters at
> com.paulwithers.openLog.OpenLogErrorHolder.getInterpretException(OpenLogErrorHolder.java:113)
> ... 52 more

2 个答案:

答案 0 :(得分:1)

与Paul稍有不同(虽然他可能是正确的),但XPage运行时正在将reviewField或sectionReview的组成解释为数字,并试图找到使用数字参数运行的方法“ getItemValueInteger”。

我将专注于此:

var sectionReview:string = compositeData.section + compositeData.reviewTeam;

,因为另一个似乎毫无疑问是一个字符串;记住,“:string”是提示,而不是合同,因此,可以肯定的是,您可能希望将CompositeData.section和CompositeData.reviewTeam的组成强制为字符串。

示例:

var reviewField:string = "numberOfReviewQuestions"+compositeData.reviewTeam;
var currentNumberReview = document1.getItemValueInteger(@Text(reviewField));
var sectionReview:string = compositeData.section + compositeData.reviewTeam;    
var currentNumberSection = document1.getItemValueInteger(@Text(sectionReview));

对于我来说,我很喜欢这种方法,当CompositeData不可用时,我会得到类似结构的空指针异常,而不是数据类型错误。同样,如果document1不可用或未初始化,则该错误通常不是方法调用错误,而是document1为null或不是对象。

答案 1 :(得分:0)

最有可能是时间问题。假设您的XPage上的所有内容都经过一次处理是错误的,因此,如果它在XPage上,则必须存在。尝试使用compositeData变量时可能尚未设置。通过打印出值来确认。另一种可能性较小的是document1尚未初始化。同样,您可以通过调用标准的非参数化方法来检查代码中的内容(getNoteID()可以使用)。