Problem using RPCManager.sendRequest()

Hi, isomorphic. Here is sample codes.

ex01.jsp
<%@ page language=“java” contentType=“text/html; charset=euc-kr” %>
<%@ taglib prefix=“isomorphic” uri=“isomorphic” %>
<html>
<head>
<isomorphic:loadISC skin=“SmartClient”/>
<script>
function showNewUserWizard() {
RPCManager.sendRequest({
actionURL:“getUserName.jsp”,
callback:“doShow(rpcResponse)”
});
}
function doShow(rpcResponse) {
Window.create({
items:[
Canvas.create({
contents:"Hello, " + rpcResponse.userName
})
]
});
}
</script>
</head>
<body>
<script>
Button.create({
title:“New User..”,
click:“showNewUserWizard()”
});
</script>
</body>
</html>

getUserName.jsp
<%@ page language=“java” contentType=“text/plain; charset=euc-kr” %>
{userName:“siri”}

Result is “Hello, undefined”. what’s wrong??

Yeah, that’s not going to work :slight_smile:

From the SDK home page, open Examples -> Server Integration -> Generic RPC Integration and take a look at the server side piece in particular.

The RPCManager is pretty flexible, but it does have some structure and there are APIs that you need to use on the server to get the data sent from the client and return a response.

it’s working as u said. but i have more question.

var data = { here:“is some data”, to:[“send to the server”] };
RPCManager.sendRequest({
data: data,
callback: “myCallback(data)”,
actionURL: “/jsps/rpcHandler.jsp”
});
function myCallback(data) {
alert("response from the server: " + data);
document.writeln("response from the server: " + data);
}

above code is working well, but i found wrong, while i was testing RPCManager batch.
server side received data from client very well. but, client’s callback function is not worked.

RPCManager.startQueue();
RPCManager.send(“a string of data”, “myCallBack(data)”, {
actionURL:“rpcHandler2.jsp”
});
RPCManager.sendRequest({
data:[“some”, “more data”, 2],
callback:“myCallback(data)”,
actionURL:“rpcHandler2.jsp”
});

RPCManager.sendRequest({
data:“different callback”,
callback:“myCallback2(data)”,
actionURL:“rpcHandler2.jsp”
});

RPCManager.sendQueue();
function myCallback(data) {
alert("response from the server: " + data);
document.writeln("response from the server: " + data);
}
function myCallback2(data) {
alert("response from the server (other callback): " + data);
document.writeln("response from the server (other callback): " + data);
}

myCallback() and myCallback2() 's alert function is not worked. why don’t callback functions worked??

That’s because the callback function is defined as “myCallback”, but you’re calling it as “myCallBack” - note the capitalized ‘B’. When you fix that, you’re going to find that document.writeln() destroys everything on the page, so you probably don’t want to do that.