Project Wonder 5.0

er.ajax
Class AjaxProxy

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WOComponent
          extended by er.ajax.AjaxComponent
              extended by er.ajax.AjaxProxy
All Implemented Interfaces:
com.webobjects.appserver.WOActionResults, com.webobjects.foundation.NSKeyValueCoding, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCodingAdditions, com.webobjects.foundation.NSValidation, IAjaxElement, java.io.Serializable, java.lang.Cloneable

public class AjaxProxy
extends AjaxComponent

Handles javascript-java communication (client-server) between the javascript world running in a web browser and the java world, running in a WebObject application. This remote-procedure-call communication is done using json protocol, as implemented by the JSON-RPC library.

This component generate 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. A 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)
// index of the selection on the client;
var idx = 3; // fixed value for the demo
// using rpc, ask our page to get the name for that client for that index.
var nom = jsonrpc.wopage.clientNameAtIndex(idx);
// Java-WebObject side, we receive the index and simple return what they asked for, as for any java call. public String clientNameAtIndex(int i) {
return "something!"+i;
}

Remember that is no proxy object is given, it will use the parent component, which is the component in which this component is embeded.

Todo

Version:
$Revision $, $Date $
© 2005-2006 OS communications informatiques, inc. http://www.os.ca Tous droits réservés.
See Also:
Serialized Form
Author:
Jean-François Veillette
Bindings
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.
           
proxyName Client side name (Javascript) used to identify the proxy (Java) from the bridge object.
           
name Client side name (Javascript) of the bridge object.
           
JSONRPCBridge Server side object (Java) used to handle the request. Of no value are bound, a new object is created for every ajax request. If a binding is there but null value, a new object will be created and pushed to the binding so that this new object can be shared for multiple proxy.
           

Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.appserver.WOComponent
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
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.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
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
 
Field Summary
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSValidation
_CLASS
 
Constructor Summary
AjaxProxy(com.webobjects.appserver.WOContext context)
           
 
Method Summary
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_".
 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
 boolean synchronizesVariablesWithBindings()
          Overridden because the component does not synch with the bindings.
 
Methods inherited from class er.ajax.AjaxComponent
_containerID, addScriptResourceInHead, addScriptResourceInHead, addStylesheetResourceInHead, addStylesheetResourceInHead, appendTagAttributeToResponse, appendToResponse, booleanValueForBinding, invokeAction, safeElementID, shouldHandleRequest, valueForBinding, valueForBinding, valueForBinding
 
Methods inherited from class com.webobjects.appserver.WOComponent
_associationWithName, _awakeInContext, _childTemplate, _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, sleep, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AjaxProxy

public AjaxProxy(com.webobjects.appserver.WOContext context)
Method Detail

isStateless

public boolean isStateless()
Overridden because the component is stateless

Overrides:
isStateless in class com.webobjects.appserver.WOComponent

synchronizesVariablesWithBindings

public boolean synchronizesVariablesWithBindings()
Overridden because the component does not synch with the bindings.

Overrides:
synchronizesVariablesWithBindings in class com.webobjects.appserver.WOComponent

addRequiredWebResources

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_".

Specified by:
addRequiredWebResources in class AjaxComponent
Parameters:
res -

handleRequest

public 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.

Specified by:
handleRequest in interface IAjaxElement
Specified by:
handleRequest in class AjaxComponent

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.