org.apache.turbine.modules.screens
Class JSONScreen
java.lang.Object
org.apache.turbine.modules.Assembler
org.apache.turbine.modules.Screen
org.apache.turbine.modules.screens.RawScreen
org.apache.turbine.modules.screens.JSONScreen
- Direct Known Subclasses:
- JSONSecureScreen
public class JSONScreen
- extends RawScreen
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
- Version:
- $Id: JSONScreen.java 958672 2010-06-28 18:42:04Z tv $
- Author:
- brad@folkens.com, Scott Eade
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JSONRPC_CONTENT_TYPE
protected static final String JSONRPC_CONTENT_TYPE
- See Also:
- Constant Field Values
BUFFER_SIZE
protected static final int BUFFER_SIZE
- See Also:
- Constant Field Values
JSONScreen
public JSONScreen()
getContentType
protected String getContentType(RunData data)
- Deprecated. Use PipelineData version instead.
- Description copied from class:
RawScreen
- Set the content type. This method should be overidden to
actually set the real content-type header of the output.
- Specified by:
getContentType
in class RawScreen
- Parameters:
data
- Turbine information.
- Returns:
- A String with the content type.
- See Also:
RawScreen.getContentType(org.apache.turbine.util.RunData)
getContentType
protected String getContentType(PipelineData pipelineData)
- Description copied from class:
RawScreen
- Set the content type. This method should be overidden to
actually set the real content-type header of the output.
- Overrides:
getContentType
in class RawScreen
- Returns:
- A String with the content type.
- See Also:
RawScreen.getContentType(org.apache.turbine.pipeline.PipelineData)
doOutput
protected void doOutput(RunData data)
throws Exception
- Deprecated. Use PipelineData version instead.
- Output the dynamic content.
- Specified by:
doOutput
in class RawScreen
- Parameters:
data
- The RunData object.
- Throws:
Exception
Copyright © 2000-2011 The Apache Software Foundation. All Rights Reserved.