我有一个执行以下操作的按钮: 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>
感谢您的任何指示。 ---莉莎&安培;
答案 0 :(得分:0)
我不确定这是否有效,但可能是它正在缓存视图内容(在视图上有效地执行setAutoUpdate(false)
)。可能有效的是,而不是onComplete
事件进行部分刷新,将SSJS末尾的服务器端调用添加到context.reloadPage()
。这将再次重新创建所有组件。从理论上讲,我希望转储它的缓存版本的视图并从头开始检索它。您还应该能够通过部分刷新而不是当前已编码的完整刷新来执行此操作。
请参阅此博客文章,我确实解释了完全刷新,context.reloadPage
,context.redirectToPage()
等http://www.intec.co.uk/viewscope-full-refresh-reloadpage/之间的差异。