void addCallback(JSObject source,String method,JSFunction callback,boolean async){
  String key=source.toJSPointer() + "." + method;
  callbacks.put(key,callback);
  String id=JSObject.ID_KEY;
  String self=source.toJSPointer();
  String js=self + "." + method+ "=function(){"+ "var len=arguments.length;var url='/!cn1command/"+ self+ "."+ method+ "?'; "+ "for (var i=0; i<len; i++){"+ "var val = arguments[i]; var strval=val;"+ "if ( (typeof(val) == 'object') || (typeof(val) == 'function')){ "+ "var id = val."+ id+ "; "+ "if (typeof(id)=='undefined' || typeof("+ jsLookupTable+ "[id]) == 'undefined' || "+ jsLookupTable+ "[id]."+ id+ "!=id){"+ jsLookupTable+ ".push(val); id="+ jsLookupTable+ ".indexOf(val); Object.defineProperty(val,\""+ id+ "\",{value:id, enumerable:false});"+ "}"+ "strval='"+ jsLookupTable+ "['+id+']'"+ "}"+ "url += encodeURIComponent(typeof(val))+'='+encodeURIComponent(strval);"+ "if (i < len-1){ url += '&';}"+ "} window.location.href=url;"+ "}";
  exec(js,async);
}

void addCallback ( JSObject source , String method , JSFunction callback , boolean async ) { String key = source . toJSPointer ( ) + "." + method ; callbacks . put ( key , callback ) ; String id = JSObject . ID_KEY ; String self = source . toJSPointer ( ) ; String js = self + "." + method + "=function(){" + "var len=arguments.length;var url='/!cn1command/" + self + "." + method + "?'; " + "for (var i=0; i<len; i++){" + "var val = arguments[i]; var strval=val;" + "if ( (typeof(val) == 'object') || (typeof(val) == 'function')){ " + "var id = val." + id + "; " + "if (typeof(id)=='undefined' || typeof(" + jsLookupTable + "[id]) == 'undefined' || " + jsLookupTable + "[id]." + id + "!=id){" + jsLookupTable + ".push(val); id=" + jsLookupTable + ".indexOf(val); Object.defineProperty(val,\"" + id + "\",{value:id, enumerable:false});" + "}" + "strval='" + jsLookupTable + "['+id+']'" + "}" + "url += encodeURIComponent(typeof(val))+'='+encodeURIComponent(strval);" + "if (i < len-1){ url += '&';}" + "} window.location.href=url;" + "}" ; exec ( js , async ) ; }
adds a jsfunction to handle calls to the specified javascript object . this essentially installed a javascript proxy method that sends a message via a navigation callback to the javascriptcontext so that it can cause java code to be executed .
