viewpanel 不显示最新数据

viewpanel not showing the latest data

我有一个按钮可以执行以下操作: 1) 删除表格中的当前信息。 2) 运行 javascript 以在表单中创建新条目。

信息显示在视图面板中。问题是显示的信息不完整且陈旧。我添加了一个仅进行部分刷新的附加按钮。第一个按钮完成后 运行,我单击第二个面板,第二次刷新显示最新数据。我一直在玩 XSP.partialRefreshGet("#{id:WrapperPanel}", {}); 的变体在第一个按钮的 oncomplete 事件中 - 无济于事。

代码如下:

<xp:button id="button34"
                                value="Check Teacher Information"
                                styleClass="BlueButtonSmall">
                                <xp:eventHandler event="onclick"
                                    submit="true" refreshMode="complete" id="eventHandler50">
                                    <xp:this.action><![CDATA[#{javascript:var serverName:NotesDatabase = database.getServer();
var PosdbName = new Array(serverName,"Position.nsf");
var CamdbName = new Array(serverName,"Campus.nsf");
var currentDB:NotesDatabase=session.getCurrentDatabase(); 

//Delete old records
var i = 0;
var  crview = database.getView("ChangeReport");
var crvec:NotesViewEntryCollection = crview.getAllEntries();
var crentry:NotesViewEntry = crvec.getFirstEntry();
while (crentry != null) {
    crDoc = crentry.getDocument();
    crDoc.remove(true);
    crDoc.recycle(); 
    if (i > 100) {
        print("Possible Loop HRMainX - breaking");
        break;
    }
    i++
    var tmpentry:NotesViewEntry = crvec.getNextEntry(crentry);
    crentry.recycle();
    crentry = tmpentry;

}
database.updateFTIndex(false);

var aview = database.getView("NISDTeacher");
var vec:NotesViewEntryCollection = aview.getAllEntries();
var entry:NotesViewEntry = vec.getFirstEntry();

var i = 0;
while (entry != null) {
    var Enumber:string = entry.getDocument().getItemValueString("TeacherEnumber");
    var Firstname = entry.getDocument().getItemValueString("TeacherFirst");
    var Lastname = entry.getDocument().getItemValueString("TeacherLast");

    var Active = @DbLookup(PosdbName,"All",Enumber,"Posd_Active");
    var Status = @DbLookup(PosdbName,"All",Enumber,"Posd_Status");
    if (Active === "Y" || Status === "A") {

        var CurrCampusNum = @DbLookup(PosdbName,"ActiveID",Enumber,"Posd_Campus");
        var CurrCampusType = @DbLookup(CamdbName,"Campus",CurrCampusNum,"Cmp_Level");
        if (CurrCampusType === "SP" || CurrCampusType === "EL" || CurrCampusType === "MS" || CurrCampusType === "HS") {

            var CampusNum = entry.getDocument().getItemValueString("CampusNum");
            var PositionCode = entry.getDocument().getItemValueString("TeacherPCode");

            var CurrFirstname = @Trim(@ProperCase(@DbLookup(PosdbName,"ActiveID",Enumber,"Posd_FName")));
            var CurrLastname = @Trim(@ProperCase(@DbLookup(PosdbName,"ActiveID",Enumber,"Posd_lname")));
            var CurrPositionCode = @DbLookup(PosdbName,"ActiveID",Enumber,"Posd_Job_Code");

            if (CurrFirstname !== Firstname) {
                var reportDate = session.createDateTime(@Now());
                var changeDoc = currentDB.createDocument();
                changeDoc.replaceItemValue("Form","ChangeReport");
                changeDoc.replaceItemValue("DateReported",reportDate);
                var Change = Enumber + " " + Firstname + " " + Lastname + " has a new Firstname of " + CurrFirstname;
                changeDoc.replaceItemValue("Change",Change)
                changeDoc.save();
            }
            if (CurrLastname !== Lastname) {
                var reportDate = session.createDateTime(@Now());
                var changeDoc = currentDB.createDocument();
                changeDoc.replaceItemValue("Form","ChangeReport");
                changeDoc.replaceItemValue("DateReported",reportDate);
                var Change = Enumber + " " + Firstname + " " + Lastname + " has a new Lastname of " + CurrLastname;
                changeDoc.replaceItemValue("Change",Change)
                changeDoc.save();
            }
            if (CurrCampusNum !== CampusNum) {
                var reportDate = session.createDateTime(@Now());
                var changeDoc = currentDB.createDocument();
                changeDoc.replaceItemValue("Form","ChangeReport");
                changeDoc.replaceItemValue("DateReported",reportDate);
                var CampusName = entry.getDocument().getItemValueString("CampusName");
                var CurrCampusName = @DbLookup(CamdbName,"Campus",CurrCampusNum,"Cmp_ShortName");
                var Change = Enumber + " " + Firstname + " " + Lastname + " was teaching at " + CampusName + " (" + CampusNum + ") " +
                "and is now teaching at " + CurrCampusName + " (" + CurrCampusNum + ")";
                changeDoc.replaceItemValue("Change",Change)
                changeDoc.save();
            }
            if (CurrPositionCode !== PositionCode) {
                var reportDate = session.createDateTime(@Now());
                var changeDoc = currentDB.createDocument();
                changeDoc.replaceItemValue("Form","ChangeReport");
                changeDoc.replaceItemValue("DateReported",reportDate);
                var PositionTitle = entry.getDocument().getItemValueString("TeacherPTitle");
                var CurrPositionTitle = @DbLookup(PosdbName,"ActiveID",Enumber,"Posd_Title");
                var Change = Enumber + " " + Firstname + " " + Lastname + " was teaching " + PositionTitle + " (" + PositionCode + ") " +
                "and is now teaching " + CurrPositionTitle + " (" + CurrPositionCode + ")";
                changeDoc.replaceItemValue("Change",Change)
                changeDoc.save();
            }

        } else {
            var reportDate = session.createDateTime(@Now());
            var changeDoc = currentDB.createDocument();
            changeDoc.replaceItemValue("Form","ChangeReport");
            changeDoc.replaceItemValue("DateReported",reportDate);
            var Change = Enumber + " " + Firstname + " " + Lastname + " no longer works as a classroom teacher.";
            changeDoc.replaceItemValue("Change",Change);
            changeDoc.save();
        }

    } else {
        var reportDate = session.createDateTime(@Now());
        var changeDoc = currentDB.createDocument();
        changeDoc.replaceItemValue("Form","ChangeReport");
        changeDoc.replaceItemValue("DateReported",reportDate);
        var Change = Enumber + " " + Firstname + " " + Lastname + " no longer works at the district.";
        changeDoc.replaceItemValue("Change",Change)
        changeDoc.save();
    }
    var tmpentry:NotesViewEntry = vec.getNextEntry(entry);
    entry.recycle();
    entry = tmpentry;
    if (i > 2000) {
        print("Possible Loop HRMainX - breaking");
        break;
   }
   i++
}
database.updateFTIndex(false);

//view.postScript("alert('Done checking teacher information.')");
viewScope.resultsCellVis = true;
//view.postScript("partialRefreshPost('#{id:WrapperPanel}')")



    }]]></xp:this.action>

                                    <xp:this.onComplete><![CDATA[XSP.partialRefreshGet("#{id:WrapperPanel}", {});]]></xp:this.onComplete>
                                </xp:eventHandler>
                            </xp:button>

感谢您的指点。 ---丽莎&

我不确定这是否有效,但可能是它正在缓存视图内容(有效地在视图上执行 setAutoUpdate(false))。可能有用的是,不是 onComplete 事件进行部分刷新,而是在 SSJS 末尾添加服务器端调用到 context.reloadPage()。这将再次重新创建所有组件。从理论上讲,我希望转储它的视图缓存版本并从头开始检索它。您还应该能够通过部分刷新而不是您当前编码的完全刷新来执行此操作。

查看此博客 post 我确实解释了完全刷新、context.reloadPagecontext.redirectToPage() 等之间的区别 http://www.intec.co.uk/viewscope-full-refresh-reloadpage/