The callback function has to be the third parameter. The fourth parameter is for is for any other arguments, that you want to path to the remote function. Passing functions directly as arguments is not possible. The given function would be executed in the scope of the container, which means that you could inject JavaScript from the gadget directly into the container.
2011/2/15 Ryan J Baxter <[email protected]> > I have an RPC call being made inside a feature I am writing. The handler > lives in the container. Here is the Javascript in my feature: > > gadgets['foo'] = (function() { > gadgets.rpc.call(null, 'bar', null, function(){....}); > > return { > getWorld : function(callback) { > gadgets.rpc.call(null, 'world', null, callback); > } > })(); > > When the handler gets called in the container the function I pass in the > rpc.call function (4th parameter) does not get passed into the handler. > Even if I make the 4th parameter a JSON object containing a function it > strips the function out of the object. Is this done on purpose? > > The other problem I have is my world RPC handler, also residing in the > container, will not receive the callback parameter either. The odd part > is that the world handler works fine if I don't have the gadget.rpc.call > to bar above it. > > Any help or explanation would be appreciated. > > -Ryan > > Email: [email protected] > Phone: 978-899-3041 > developerWorks Profile > > > > From: Bastian Hofmann <[email protected]> > To: [email protected], > Date: 02/15/2011 03:53 AM > Subject: Re: Manipulating Data Context From A Container > > > > You could do this the other way round: > > On the gadget side you could register yourself to the onload event > (gadgets.util.registerOnLoadHandler) and send an rpc call to the > container. > > gadgets.rpc.call('..', 'put_data_set', function(dataSets) { > > opensocial.data.DataContext. > putDataSets(dataSets); > > > }, null); > > > The container side can create the data set object and pass it to the > gadget > via the specified callback, which in turn sets the new dataset on the > gadget > side: > > gadgets.rpc.register('put_ > data_set', function() { > this.callback(object); > }); > > > 2011/2/15 Ryan J Baxter <[email protected]> > > > Is there any way to know when a gadget is rendered in the container so I > > can make an RPC call to the gadget from the container? The function > > callSameDomain is throwing an error, Same domain call failed: parent= > > incorrectly set., because targetEl.gadgets is undefined. targetEl is > the > > target window the RPC call is going to. I am assuming targetEl.gadgets > is > > undefined because the iFrame with the gadget has not completely rendered > > yet. If I hold off on making the RCP call everything works fine. > > > > -Ryan > > > > Email: [email protected] > > Phone: 978-899-3041 > > developerWorks Profile > > > > > > > > From: Bastian Hofmann <[email protected]> > > To: [email protected], > > Date: 02/14/2011 03:27 AM > > Subject: Re: Manipulating Data Context From A Container > > > > > > > > No, > > > > if you add something like the following on the gadget side: > > > > gadgets.rpc.register('put_data_set', function(dataSets) { > > opensocial.data.DataContext.putDataSets(dataSets); > > }); > > > > you can call the rpc method put_data_set from your container: > > > > gadgets.rpc.call('gadget_iframe_id', 'put_data_set', null, {key: > value}); > > > > And the registered method will be called on the gadget side > automatically. > > > > Hope this helps > > > > Bastian > > > > 2011/2/11 Ryan J Baxter <[email protected]> > > > > > Brian wouldn't this still require the gadget to call putDataSet? I > > don't > > > want the gadget to have to do anything, instead I would like to put > > > something in the data context for a gadget from the container. That > way > > > the gadget can just use it. > > > > > > -Ryan > > > > > > Email: [email protected] > > > Phone: 978-899-3041 > > > developerWorks Profile > > > > > > > > > > > > From: Bastian Hofmann <[email protected]> > > > To: [email protected], > > > Date: 02/10/2011 05:01 PM > > > Subject: Re: Manipulating Data Context From A Container > > > > > > > > > > > > You probably will have to register the > > > opensocial.data.DataContext.putDataSet method as an rpc method on the > > > gadget > > > side and then use rpc to push the data from the container (similar to > > the > > > current implementation of a security token update (auth-refresh)). > > > > > > Cheers > > > > > > Bastian > > > > > > 2011/2/10 Ryan J Baxter <[email protected]> > > > > > > > I would like to be able to set something in a gadgets data context > > > object > > > > from the container. The feature only provides the javascript API to > > the > > > > gadget, which makes sense. It looks as though things are inserted > > into > > > > the data context object by injecting the javascript to do so when > the > > > > gadget is rendered. Looks like PipelineDataGadgetRewriter.java does > > > this. > > > > Does anyone know is its possible to manipulate a gadget's data > > context > > > > object from the container? At the moment it does not look like it > is. > > > > > > > > -Ryan > > > > > > > > Email: [email protected] > > > > Phone: 978-899-3041 > > > > developerWorks Profile > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
