Sample XHR request to portelt

This is the sample of how you can send the XHR request to the portlet and call its serveResource() method. Click here to download sample portlet


The sample in Infocenter about _portletWindow.newXMLPortletRequest never works. Even though i can see the XHR request my callback does not get called.




<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="false"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@taglib
uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"
prefix="portlet-client-model"%>
<portlet-client-model:init>
<portlet-client-model:require module="ibm.portal.xml.*" />
<portlet-client-model:require module="ibm.portal.portlet.*" />
</portlet-client-model:init>
<portlet:defineObjects />
<div id="test">initial text</div>
<script language="JavaScript">
function handleOnClick(){
console.log("Exiting handleOnClick");
dojo.xhrGet({
url: '<portlet:resourceURL/>',
load: function(data){
console.log("load is called");
dojo.byId("test").innerHTML = data;
},
error: function(data){
console.log("error is called")
}
});

console.log("Exiting handleOnClick");
}
</script>
<p><input type="submit" name="Test" value="Test" onclick="handleOnClick()"></p>

No comments: