Eri*_*ick 1 java lotus-notes xpages notesview
我在一些代码中遇到一个有趣的错误,这些错误与我在其他地方工作的代码几乎相同(至少在结构上).我得到一个"注释错误:索引中找不到条目"错误,它出现在我的ViewNavigator.getNext(ViewEntry)的while循环中.我觉得我在这个问题上遗漏了一些明显的东西,所以希望有人能发现它(我只是盯着它看起来很麻烦).
[更新] Jesse关于将autoUpdate设置为false的说明就行了.它似乎与2002年的技术说明有关,因为我的循环在此循环期间保存到另一个文档(相同的DB,不同的View).我vw.setAutoUpdate(false);在View上定义了句柄后立即放置了.[/更新]
我正在走一个单一类别的视图(通过视图中每个文档的引用字段值)来汇总分组文档中的一些信息.启用调试后,我发现错误发生在我从第一个类别的最后一个Document(ViewEntry of Doc)回到类别(ViewEntry)的遍历中.
这是我的代码的精简版本(// ...表示为清晰起见删除了行):
View vw = db.getView("<ViewName>");
ViewNavigator nav = vw.createViewNav();
ViewEntry first = nav.getFirst();
String unid = "";
while(first != null){
if(first.isCategory()){
if(!unid.isEmpty()){
//summarize the info and save it back to the category-relevant doc
Document myDoc = db.getDocumentByUNID(unid);
//doing my thing
boolean success = myDoc.save(true, false);
myDoc.recycle();
}
unid = "";
}
if(first.isDocument()){
Vector<?> colVals = first.getColumnValues();
if(unid.isEmpty()){
//reset temp aggregation vars back to initial value (e.g.- 0)
//...
unid = (String) colVals.get(5); // the value of the category-relevant UNID
}else{
//doing the aggregation of summary values with the temp vars established before and handled after
//...
//perform aggregation from colVals with temp vars
}
session.recycle(colVals);
}
ViewEntry tmp = nav.getNext(first); //this is the line that fails!! only if it's the next category, which there is one
first.recycle();
first = tmp;
}
Run Code Online (Sandbox Code Playgroud)
设置view.setAutoUpdate(false)应该清除它,可能是因为文件保存在那里.
我发现在获取视图后一直设置这个是一个很好的策略(我相信ODA会在Khan模式下自动完成).然后它还允许您设置nav.setBufferMaxEntries(400),这可以改善冗长的视图导航.