Proxy Callbacks

If you're using the wwAjaxMethodCallback server control you can optionally have the control create proxy wrappers for all exposed server methods. This makes it super easy to call server methods with a single line of code.

An autogenerated proxy looks something like this embedded into client script:

var Callback = { 
    GetResourceList: function (ResourceSet,CallbackHandler,ErrorHandler)
    {
        var _cb = Callback_GetCallback();
        _cb.callMethod('GetResourceList',[ResourceSet],CallbackHandler,ErrorHandler);
        return _cb;           
    },
    GetResourceString: function (ResourceId,ResourceSet,CultureName,CallbackHandler,ErrorHandler)
    {
        var _cb = Callback_GetCallback();
        _cb.callMethod('GetResourceString',[ResourceId,ResourceSet,CultureName],CallbackHandler,ErrorHandler);
        return _cb;           
    },
}

Where Callback is the name of your wwAjaxMethodCallback control on the page.

And you can then call any of the methods simply with:


// *** Start the callback
Callback.GetResourceList("Resources",GetResourceList_Callback,OnPageError);
...

// *** Handle the result from the callback
function GetResourceList_Callback(Result)
{
	... do something with the result here
     alert(Result.toString());
}
// *** Handle errors - typically generically for the all callbacks
function OnPageError(Error)
{
	alert("Page Error: " + Error.message);
}

Proxy Generation

When using the wwAjaxMethodCallback Class the client proxy generation is automatically enabled by default. It works by looking at the target object that handles requests and looking for all methods that have the [CallbackMethod] attribute defined via Reflection.

If you prefer you can surpress the proxy generation by setting the GenerateClientProxyClass property to false.


© West Wind Technologies, 1996-2016 • Updated: 10/03/08
Comment or report problem with topic