public class AjaxProxy extends AjaxComponent
This component generates javascript code that will initialize a variable that will be the starting point for rpc
communication. The name of this variable is given in the name
binding. There will be an object, server
side that will be the proxy and will handle the request. You can define the proxy on the server side (it has to be a
JSONRPCBridge). The proxy will be your window to the java world, from there you can access your java objects from the
javascript side. The name for this java variable is proxyName
. By default, it will configure the
parent component as one java proxy object and name it wopage
from the javascript side.
(WARNING: DON'T DO THIS. YOU SHOULD ALWAYS PROVIDE A SEPARATE PROXY OBJECT. See below.) The JSONRPCBridge
object is created if not given as a binding. If the binding is there but the value is null, it will create the bridge
then push it to the binding. That way, you can configure a single bridge for multiple proxy objects. It is of good
practice to provide a value in a binding (at least a binding) so that the object is not created on every ajax
request.
The proxy object will be the one visible for RPC from the javascript world. For example, the following
binding:
PageProxy : AjaxProxy {
proxyName = "wopage";
name = "jsonrpc";
}
will be used as follow :
JavaScript (client) | Java (server) |
---|---|
|
|
Every public instance and static method of the proxy object is published on the javascript side. Remember that if no proxy object is given, it will use the parent component, which is the component in which this component is embedded. This is probably a very bad idea, as it possible to call something like 'valueForKeyPath("application.terminate")' from the client side. And you usually don't control the client.
You currently cannot publish more than one proxy object under a given bridge "name" (e.g. "jsonrpc"). The initialization code will only be called for the first object.
Note: The component used to have a binding "JSONRPCBridge". This seems to been renamed to "AjaxBridge". Both bindings are supported. In future versions the JSONRPCBridge may be removed.
JSONRPCBridge.registerObject(Object, Object, Class)
Name | Description |
---|---|
proxy | Server side object (Java) that will be visible for rpc communication (Javascript). If no object is bound, the parent() object is assigned by default. You should ALWYAS provide an object. |
proxyName | Client side name (Javascript) used to identify the proxy (Java) from the bridge object. |
name | Client side name (Javascript) of the bridge object. |
AjaxBridge | Server side object (Java) used to handle the request. If no value is bound, a new object is created for every ajax request. If a binding is there but has a null value, a new object will be created and pushed to the binding so that this new object can be shared for multiple proxies. |
lazy | (default false) if true, the proxy is only initialized on-demand, rather than on-load. The initialization requests the available methods from the proxy object. |
WOComponent._EventLoggingEnabler, WOComponent.Event
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
NSKeyValueCoding._BooleanFieldBinding, NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._FieldBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberFieldBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null<T>, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException
_Extension, _IsEventLoggingEnabled, _keyAssociations
_CLASS
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
NullValue
_CLASS
Modifier and Type | Method and Description |
---|---|
protected void |
addRequiredWebResources(WOResponse res)
Adds the jsonrpc.js script to the head in the response if not already present and also adds a javascript proxy
for the supplied bridge under the name "JSONRPC_<variableName>".
|
WOActionResults |
handleRequest(WORequest request,
WOContext context)
Ask the an JSONRPCBridge object to handle the json request.
|
boolean |
isStateless()
Overridden because the component is stateless
|
_containerID, addScriptResourceInHead, addScriptResourceInHead, addStylesheetResourceInHead, addStylesheetResourceInHead, appendTagAttributeToResponse, appendToResponse, booleanValueForBinding, invokeAction, safeElementID, shouldHandleRequest, valueForBinding, valueForBinding, valueForBinding
__valueForBinding, _associationWithName, _awakeInContext, _childTemplate, _cleanUpStatelessComponent, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, application, awake, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, isCachingEnabled, isEventLoggingEnabled, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, reset, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, setVariableValueForName, sleep, synchronizesVariablesWithBindings, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithHTMLString, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForBooleanBinding, valueForIntegerBinding, valueForKey, valueForKeyPath, valueForNSArrayBindings, valueForNSDictionaryBindings, valueForNumberBinding, valueForStringBinding, variableValueForName, variableWithName
public AjaxProxy(WOContext context)
public boolean isStateless()
isStateless
in class WOComponent
protected void addRequiredWebResources(WOResponse res)
addRequiredWebResources
in class AjaxComponent
res
- the response to write intopublic WOActionResults handleRequest(WORequest request, WOContext context)
handleRequest
in interface IAjaxElement
handleRequest
in class AjaxComponent
request
- the requestcontext
- the contextCopyright © 2002 – 2024 Project Wonder.