也许您可以使用循环和 try...catch 来处理错误。我不确定 xpages 所需的确切语法,但可能是这样的:
docColl = database.search(formula);
exceptionCaught = true;  // little white lie
while(exceptionCaught = true);
{
  getComponent("TempName").setValue(docColl.getCount());
  exceptionCaught = false;
  try
  {
    docColl.putAllInFolder("f_Statistics");
  }
  catch (Exception e)
  {  // It blew up; assume that this means there were too many docs
     View folder = db.getView("f_Statistics");
     docColl.Subtract(folder.getAllEntries();
     exceptionCaught = true;
  }
}
是的,这是一个黑客。
不...上面没有经过测试,甚至没有检查语法。我只是把这个想法扔掉。
如果你尝试这个,我强烈建议你做一些额外的检查,以确保异常的原因确实是文档的数量,因为如果发生任何其他异常,上面的代码很可能是一个无限循环!