Klasse PlainJSONScreen
java.lang.Object
org.apache.turbine.modules.screens.RawScreen
org.apache.turbine.modules.screens.PlainJSONScreen
- Bekannte direkte Unterklassen:
PlainJSONSecureAnnotatedScreen
A Screen class for dealing with JSON requests. Typically you would
extend this class and override the doOutput() method to use it by setting the JSON output into
rundata.setMessage( serialized ).
As convenience you may use inject in your extended class the Turbine service JsonService
Use
PlainJSONSecureAnnotatedScreen
if you need the user to be
logged in or having a special role in prior to executing the functions you provide.
Here is an example from a subclass:
public void doOutput(PipelineData pipelineData) throws Exception
{
RunData data = pipelineData.getRunData();
JSONStrategy strategy = null;
try
{
strategy = new XYStrategy();
// the result goes into rundata.message
strategy.execute(data, jsonService);
}
catch ( Exception e )
{
log.error( "init failed for "+strategy , e);
String msg = new JSONObject().put("error", e.getMessage()).toString();
data.setMessage( msg );
}
super.doOutput(data);
}
- Version:
- $Id$
- Autor:
- gk
-
Feldübersicht
FelderVon Schnittstelle geerbte Felder org.apache.turbine.modules.Screen
CACHE_SIZE_DEFAULT, CACHE_SIZE_KEY, NAME, PREFIX
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected void
doOutput
(PipelineData pipelineData) Output JSON content set intoRunData.getMessage()
.protected String
getContentType
(PipelineData pipelineData) Set the content type.
-
Felddetails
-
JSON_TYPE
- Siehe auch:
-
BUFFER_SIZE
- Siehe auch:
-
-
Konstruktordetails
-
PlainJSONScreen
public PlainJSONScreen()
-
-
Methodendetails
-
getContentType
Beschreibung aus Klasse kopiert:RawScreen
Set the content type. This method should be overridden to actually set the real content-type header of the output.- Angegeben von:
getContentType
in KlasseRawScreen
- Parameter:
pipelineData
- Turbine information.- Gibt zurück:
- A String with the content type.
- Siehe auch:
-
doOutput
Output JSON content set intoRunData.getMessage()
. Encoding is UTF-8. @JSON_TYPE
: "application/json;charset=utf-8".
-