Passing data to your application through requestNavigateTo() †
If you are using the opensocial.requestNavigateTo() calls, you may supply an optional parameter containing data to be passed to the new page.
The following code passes two variables: foo and bar to the canvas surface of the current application:
function gotoCanvas(params) {
var canvas_surface = new opensocial.Surface("canvas");
opensocial.requestNavigateTo(canvas_surface, params);
};
var my_params = {
foo : 12345,
bar : "Bar value"
};
gotoCanvas(my_params);
In the canvas view, check for these values with the following code:
var prefs = opensocial.getEnvironment().getParams();
var foo = prefs["foo"];
/* foo contains 12345 */
var bar = prefs["bar"];
/* bar contains "Bar value" */
You should see that after the navigation has taken place, your URL will look similar to:
http://sandbox.orkut.com/Application.aspx?appId=xxxxxx&uid=xxxxxx&appParams=foo%3D12345%26bar%3DBar%20value
This follows the same format as discussed in Passing data to your application through the querystring
No comments:
Post a Comment