public class JSONComponent extends Object
The base class for JSON "Components". JSONComponents provide a framework for implementing stateful JSON services. If you are providing a JSON service that is only used on a page, you can use AjaxProxy to provide a stateful JSON interface to a page. However, if you would like to provide stateful services to non-page-based clients, AjaxProxy isn't sufficient. By extending JSONComponent, all of your public methods are exposed as RPC calls to your clients that can be accessed by constructing a URL to a JSON Request Handler. For instance, /json/MyComponentName will give you a stateful service endpoint
If a method returns another JSONComponent, the client will be sent a JSONRedirect that contains the URL to communicate with the instance you returned.
THIS API IS STILL EXPERIMENTAL AND SUBJECT TO CHANGEConstructor and Description |
---|
JSONComponent(WOContext context)
Constructs a new JSONComponent.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_setContext(WOContext context)
Sets the current context.
|
protected void |
checkAccess()
Called prior to issuing any calls to
the component.
|
<T extends JSONComponent> |
componentWithName(Class<T> componentClass)
Returns a JSONComponent of the given type.
|
static <T extends JSONComponent> |
componentWithName(Class<T> componentClass,
WOContext context)
Returns a JSONComponent of the given type.
|
static <T extends JSONComponent> |
componentWithName(String componentClassName,
WOContext context)
Returns a JSONComponent of the given type.
|
protected WOContext |
context()
Returns the current context.
|
public JSONComponent(WOContext context)
context
- the context that created the componentprotected WOContext context()
protected void _setContext(WOContext context)
context
- the current context.protected void checkAccess()
public <T extends JSONComponent> T componentWithName(Class<T> componentClass)
T
- the JSONComponent typecomponentClass
- the class to instantiatepublic static <T extends JSONComponent> T componentWithName(Class<T> componentClass, WOContext context)
T
- the JSONComponent typecomponentClass
- the class to instantiatecontext
- the WOContext to create withinpublic static <T extends JSONComponent> T componentWithName(String componentClassName, WOContext context)
T
- the JSONComponent typecomponentClassName
- the name of the class to instantiatecontext
- the WOContext to create withinCopyright © 2002 – 2024 Project Wonder.