Subject: XML DOM reference (to be used with JavaScript / AJAX)
I imagine those will be pretty far off as DOM has no idea what things like RichTextItem, NotesItem, etc. are. XMLHttpRequest really doesn’t know what the Domino objects are. They are there primarily for parsing within Domino (using LS or Java or doing transformations). What you should see exposed are standard DOM items (tables, divs, spans, etc (though only if you create those items, obviously) and events. Of course, you will need to handle any cross-browser issues that come up with implementing the DOM since MS does some things differently from everyone else in the world, but that’s not really anything to do with Domino. For events, check the programming panel in designer for your form, page, or whatever and review the JS events found there for fields, forms, and so on. A quick review in the Designer Help at the NotesDom* classes looks as if the methods use the same format that you would find in javascript, but the parameters may not be the same in all cases. Your best bet is to figure out what you will need to do, and which DOM objects you need to create or manipulate, then search the web for that term to check the syntax in javascript. What is it that you are looking to do?
This code snippet illustrates part of a dom manipulation. It is a a callback function that I use after making an xmlHttpRequest to a Java agent that looks up data on our AS400 and returns it to this function to be handled:
Also, note that there are js libraries out there that simplify many of the DOM manipulations. Prototype is one I use often, though not in this case. YUI also looks very interesting, and IBM is standardizing on DOJO.
window.document.getElementById('messages').style.display = "inline";
window.document.getElementById('messages').innerHTML = "<b>Processing Store Manager lookup... District Manager lookup....<b>";
if (req.readyState == 4){
if (req.status == 200){
var msg = req.responseXML;
if (msg.parseError.errorCode != 0){
window.document.getElementById('messages').style.display = "inline";
window.document.getElementById('messages').innerHTML = "<b><u>Errors Occured obtaining the data from the AS400:</u></b><br/><div id='messagesinner'>Could not get a handle to the xml document.</br>Error code " + msg.parseError.errorCode + " " + msg.parseError.reason;
window.document.getElementById('messages').innerHTML += "</br>response text is</br>" + req.responseText + "</br>Error!!!</div>";
window.document.getElementById('messagesinner').className='ValidationFailedN';
waittofade("7");
return false;
}
var xmlDocument = msg.documentElement;
if(!xmlDocument){
//throw up an error and return false
// window.alert(“could not get the document”);
window.document.getElementById('messages').style.display = "inline";
window.document.getElementById('messages').innerHTML = "<b><u>Errors Occured obtaining the data from the AS400:</u></b><br/><div id='messagesinner'>Could not get a handle to the xml document.</br>Check the agent.";
window.document.getElementById('messages').innerHTML += "</br>response text is</br>" + req.responseText + "</br>Error!!!</div>";
document.getElementById('messagesinner').className='ValidationFailedN';
waittofade("7");
return false;
}
xmlDocument.normalize();
var xmlArray = new Array();
var firstNode = xmlDocument.getElementsByTagName("manager");
var secondNode = xmlDocument.getElementsByTagName("director");
var thirdNode = xmlDocument.getElementsByTagName("district");
var fourthNode = xmlDocument.getElementsByTagName("region");
if(firstNode[0].text != "" | firstNode[0].text != " " | firstNode[0].text != "undefined"){
//format the data as propercase
xmlArray[1] = firstNode[0].text;
}else{
xmlArray[1] = "";
}
if(secondNode[0].text != "" | secondNode[0].text != " " | secondNode[0].text != "undefined"){
//format the data as propercase
xmlArray[2] = secondNode[0].text;
}else{
xmlArray[2] = "";
}
if(thirdNode[0].text != "" | thirdNode[0].text != " " | thirdNode[0].text != "undefined"){
//format the data as propercase
xmlArray[3] = thirdNode[0].text;
}else{
xmlArray[3] = "";
}
if(fourthNode[0].text != "" | fourthNode[0].text != " " | fourthNode[0].text != "undefined"){
//format the data as propercase
xmlArray[4] = fourthNode[0].text;
}else{
xmlArray[4] = "";
}
var a1 = xmlArray[1] ;
var a2 = xmlArray[2];
var a3 = xmlArray[3];
var a4 = xmlArray[4];
a2 = toCapitalCase(a2);
a1 = toCapitalCase(a1);
a3 = toCapitalCase(a3);
a4 = toCapitalCase(a4);
frm.cpStoreManager.value = a1;
frm.cpDistrictDirector.value = a2;
frm.cpDistrict.value = a3;
frm.cpRegion.value = a4;
//parse the xml and update the manager and director fields and the stm and stdir spans
window.document.getElementById("stm").innerHTML = a1;
window.document.getElementById("stdir").innerHTML = a2;
// window.document.getElementById(“district”).innerHTML = a3;
// window.document.getElementbyId(“region”).innerhtml = a4;
window.document.getElementById('messages').style.display = "none";
window.document.getElementById('messages').innerHTML = "";
return true;
}else{
//http error handler
if(req.status == 500){
handleErrFullPage(req.responseText);
}else{
handleErrSpecific(req.status);
} //end if
} //end if
} //end if
return false;