When a user adds, changes, or deletes a record using the right pane of a form, the list in the left pane is reloaded. The code that initiates the reloading process is in the postActions method of the SQLXML object. The call to postActions passes the parameters shown in the following code fragment. The oRequest (an ASPTypeLibrary.Request object) parameter makes all elements from the Form collection of the Request object available to the postActions method.
Public Sub PostActions(ByRef oRequest As ASPTypeLibrary.Request, ByRef oResponse As ASPTypeLibrary.Response, Optional ByVal ConnectionString As String)
The following code runs as a step in the sequence of writing data to the Eval database. To simplify the discussion of reloading a left pane list, the following code fragment from postActions shows only the code that assigns a value to the returnId variable or calls the updateView function. The call to updateView contains the action the user is performing (ADD, CHANGE, or DELETE) and the returnId.
Coding postIt.asp describes how postIt.asp instantiates the SQLXML component and calls the postActions method.
Select Case UCASE(Request.Form("actionBtn"))
Case "ADD"
…
returnId = oCommand.Parameters("@" & oRequest.Form("tableName") & "Id")
Call updateView("ADD",returnId)
Case "CHANGE"
…
returnId = oRequest.Form("Id")
Call updateView("CHANGE",returnId)
Case "DELETE"
returnId = oRequest.Form("Id")
Call updateView("DELETE",returnId)
Case Else
…
End Select
The following code fragment is from the updateView method in Group.htm, but other form views contain similar code. The previous database action is examined; an add action returns the form to change mode. All actions call the reloadList function in IsValid.js; add and change actions pass the value in the Id variable to reloadList, and the delete action passes a NULL value.
function updateView(actn,id) {
switch (actn) {
case 'ADD':
// set new ID in form
document.frmGroup.elements("ID").value = id;
document.frmGroup.GroupId.value = id;
// return form to "CHANGE" mode
document.frmGroup.actionBtn.value = "CHANGE";
document.frmGroup.procName.value = "lw_changeGroup";
parent.frames("LEFTPANE").reloadList(id);
loaded();
break;
case 'DELETE':
document.frmGroup.reset();
parent.frames("LEFTPANE").reloadList(null);
break;
case 'CHANGE':
parent.frames("LEFTPANE").reloadList(id);
break;
}
}
In reloadList, the onreadystate event fires when the readyState property of xmldso (an XML DSO) changes, and the script in the dataAvailable function (LoadList.js) assigned to the onreadystate event runs. From dataAvailable, the steps to load the list are those described in Reloading the List After Table Actions. The following lines of code illustrate this process:
function reloadList(id) {
resetRows();
searchId = id;
var xmldoc = xmldso.XMLDocument;
xmldoc.ondataavailable = noOp; // won't accept null
xmldoc.onreadystatechange = dataAvailable;
xmldoc.load(xmldoc.url); // reload the current dataset
}