A Screen class for dealing with JSON-RPC requests. Typically you would
extend this class and override the doOutput() method to use TurbineJsonRpc
to register the POJOs that will provide the functions you are making
available via JSON-RPC. Use JSONSecureScreen if you need the user to be
logged in prior to executing the functions you provide.
Here is an example from a superclass:
public void doOutput(RunData data) throws Exception
{
User user = data.getUser();
MyJsonFunctions myFunctions = new MyJsonFunctions(user.getName());
// Session specific
TurbineJsonRpc.registerObject(data.getSession(), "myFunctions", myFunctions);
// Global
//TurbineJsonRpc.registerObjectGlobal("testGlobal", testObject);
super.doOutput(data);
}
The class MyFunctions would be something like:
public class MyJsonFunctions
{
private String getHello(String clientParameter)
{
return "Hello " + clientParameter;
}
}
This code is derived from the com.metaparadigm.jsonrpc.JSONRPCServlet
author: brad@folkens.com author: Scott Eade version: $Id$ |