interface XMLPortletRequest {
attribute EventListener onreadystatechange;
readonly attribute unsigned short readyState;
void open(in DOMString method, in DOMString url);
void open(in DOMString method, in DOMString url, in boolean async);
void open(in DOMString method, in DOMString url, in boolean async, in DOMString user);
void open(in DOMString method, in DOMString url, in boolean async, in DOMString user, in DOMString password);
void setRequestHeader(in DOMString header, in DOMString value);
void send();
void send(in DOMString data);
void send(in Document data);
void abort();
DOMString getAllResponseHeaders();
DOMString getResponseHeader(in DOMString header);
readonly attribute DOMString responseText;
readonly attribute Document responseXML;
readonly attribute unsigned short status;
readonly attribute DOMString statusText;
};
=\/=\/=\/=====================================================<script LANGUAGE=JavaScript>
var portletReq;
function asynchGetXMLPortletRequest(){
var requestURL = document.getElementById("fragmentURL").value;
try {
portletReq = new XMLPortletRequest();
} catch(e) {
alert("Exception: I could not find the XMLPortletRequest");
}
alert("portletReq = " + portletReq);
portletReq.onreadystatechange = processReqChange;
portletReq.open('GET', requestURL, true);
portletReq.send(null);
}
function processReqChange() {
if (portletReq.readyState == 4) {
if (portletReq.status == 200) {
displayInvoice();
}
}
}
function displayInvoice() {
var div = document.getElementById("portletcontent");
div.innerHTML = "";
div.innerHTML = portletReq.responseText;
var but = document.getElementById("mainbut");
but.value = "clear";
but.onclick = clearContent;
}
function clearContent() {
var div = document.getElementById("portletcontent");
div.innerHTML = "";
var but = document.getElementById("mainbut");
but.value = "Serve fragment";
but.onclick = asynchGetXMLPortletRequest;
}
</script>
<input type="button" id="mainbut" value="Serve fragment" onclick="asynchGetXMLPortletRequest()">
<input type="hidden" id="fragmentURL" value="<portlet:fragmentURL /> ">
<div id="portletcontent"></div>
=/\=/\=/\=====================================================
XMLPortletRequest Proposal
XMLPortletRequest - Part 1: Background
XMLPortletRequest - Part 2: Wrapping XMLHttpRequest
Web Services for Remote Portlets - HTTP Client API
XMLHttpRequest
No comments:
Post a Comment