XPage转到while循环中的nextEntry

时间:2016-03-16 15:19:37

标签: while-loop xpages

我从视图中获取文档。我想直接转到一条线,就像" GOTO"在Lotusscript中命令; 用JavaScript可以吗?

var vec:NotesViewEntryCollection = database.getView("viewName").getAllEntries();
var entry:NotesViewEntry = vec.getLastEntry();
while (entry != null) 
{
        var subject:string = entry.getDocument().getItemValueString("subject");
        if (subject=="Title1")
        {
            goto prevEntry; 
        }
        if (subject=="Title2")
        {
            goto prevEntry; 
        }
        if (subject=="Title3")
        {
            //do something here...;
        }
    //prevEntry;
        var tmpentry:NotesViewEntry = vec.getPrevEntry(entry);
        entry.recycle();
        entry = tmpentry;
}

3 个答案:

答案 0 :(得分:3)

JavaScript代码没有转到

使用continue代替将当前迭代保留在循环中并继续下一次迭代。

//do 1...

如果主题是" Title1"然后它会//do 2... 如果主题是" Title2"然后它会//do 3...What is your name? (EASTER EGG CODE: "blackbeard") >>None

答案 1 :(得分:2)

该代码可以简化为:

var vec:NotesViewEntryCollection = database.getView("viewName").getAllEntries();
var entry:NotesViewEntry = vec.getLastEntry();
while (entry != null) 
{
    var subject:string = entry.getDocument().getItemValueString("subject");
    if (subject=="Title3") {
        //do something here...;
    }
    //prevEntry;
    var tmpentry:NotesViewEntry = vec.getPrevEntry(entry);
    entry.recycle();
    entry = tmpentry;
}

答案 2 :(得分:1)

我认为你应该改变你的if语句。 如果( “TITLE3” .equals(主题){ //做一点事 }  继续使用代码和下一个条目