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. |
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.MapImplementation, com.webobjects.foundation.NSKeyValueCoding.Null<T>, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
com.webobjects.foundation.NSValidation._MethodBinding, com.webobjects.foundation.NSValidation._ValidationBinding, com.webobjects.foundation.NSValidation.DefaultImplementation, com.webobjects.foundation.NSValidation.Utility, com.webobjects.foundation.NSValidation.ValidationException
_Extension, _IsEventLoggingEnabled, _keyAssociations
Constructor and Description |
---|
AjaxProxy(com.webobjects.appserver.WOContext context) |
Modifier and Type | Method and Description |
---|---|
protected void |
addRequiredWebResources(com.webobjects.appserver.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>".
|
com.webobjects.appserver.WOActionResults |
handleRequest(com.webobjects.appserver.WORequest request,
com.webobjects.appserver.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 boolean isStateless()
isStateless
in class com.webobjects.appserver.WOComponent
protected void addRequiredWebResources(com.webobjects.appserver.WOResponse res)
addRequiredWebResources
in class AjaxComponent
res
- the response to write intopublic com.webobjects.appserver.WOActionResults handleRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
handleRequest
in interface IAjaxElement
handleRequest
in class AjaxComponent
request
- the requestcontext
- the contextCopyright © 2002 – 2020 Project Wonder.