-
-
Save garyjoy/0eab33613f561eb89c6c to your computer and use it in GitHub Desktop.
Implement a Lazy-Loading Table in a Report (on IBM BPM v7.5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is a synchronous version of "callService()" that we can use in our Lazy-Loading Data Grids. */ | |
tw.coach.callSynchronousService = function (service, params, snapshot) { | |
if (snapshot == "" || snapshot == null) { | |
snapshot = coachSnapshotContext; | |
} | |
var url = "/portal/jsp/callService.do?serviceName=" + service + "&snapshotId=" + snapshot; | |
return callSynchronousServiceImpl(url, params); | |
}; | |
/* This is a synchronous version of "callServiceImpl()" that we can use in our Lazy-Loading Data Grids. | |
The "false" in "http_request.open()" is what makes it synchronous. */ | |
function callSynchronousServiceImpl(url, params) { | |
var parameters = "input=" + encodeURIComponent(params); | |
var http_request = null; | |
if (window.XMLHttpRequest) { // Mozilla, Safari,... | |
http_request = new XMLHttpRequest(); | |
if (http_request.overrideMimeType) { | |
http_request.overrideMimeType('text/xml'); | |
} | |
} else if (window.ActiveXObject) { // IE | |
try { | |
http_request = new ActiveXObject("Msxml2.XMLHTTP"); | |
} catch (e) { | |
try { | |
http_request = new ActiveXObject("Microsoft.XMLHTTP"); | |
} catch (e) {} | |
} | |
} | |
if (!http_request) { | |
alert('Cannot create XMLHTTP instance'); | |
return false; | |
} | |
http_request.open('POST', url, false); | |
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
// The browser just complains about these so I have commented them out... | |
// http_request.setRequestHeader("Content-length", parameters.length); | |
// http_request.setRequestHeader("Connection", "close"); | |
http_request.send(parameters); | |
var ret = new Object(); | |
if (http_request.status == 200) { | |
var result = http_request.responseXML.getElementsByTagName("output"); | |
if (window.XMLHttpRequest && window.ActiveXObject) { // necessary for IE7 | |
http_request.responseXML.load(http_request.responseBody); | |
result = http_request.responseXML.getElementsByTagName("output"); | |
} | |
for (var i = 0; i < result.length; i++) { | |
var output = result[i]; | |
var name = output.getAttribute("name"); | |
ret[name] = parseValues(output.firstChild, ret); | |
} | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment