The function check is always called when the app loads. It in turn
calls onCheck function.

The following code works:
var globalTotal = 0;
var globalViewer = {};

function announce(){
globalConfig[globalViewer.getId()] = globalTotal;
var json = gadgets.json.stringify(globalConfig);

var req = opensocial.newDataRequest();
req.add(req.newUpdatePersonAppDataRequest(opensocial.DataRequest.PersonId.VIEWER,
'cfig',json));
req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
req.add(req.newFetchPersonAppDataRequest('VIEWER', 'cfig'), 'data');
req.send(onCheck);
}

function check(){
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER'),'viewer');
req.add(req.newFetchPersonAppDataRequest('VIEWER', 'cfig'), 'data');
req.send(onCheck);
}

function onCheck(){
var viewer = globalViewer = data.get('viewer').getData();
var configData = data.get('data').getData();
var json = configData[viewer.getId()]['cfig'];
}


But this one with "owner" doesn't:
var globalTotal = 0;
var gOwner = {};

function announce(){
globalConfig[gOwner.getId()] = globalTotal;
var json = gadgets.json.stringify(globalConfig);

var req = opensocial.newDataRequest();
req.add(req.newUpdatePersonAppDataRequest(opensocial.DataRequest.PersonId.OWNER,
'cfig',json));
req.add(req.newFetchPersonRequest('OWNER'), 'owner');
req.add(req.newFetchPersonAppDataRequest('OWNER', 'cfig'), 'data');
req.send(onCheck);
}

function check(){
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('OWNER'),'owner');
req.add(req.newFetchPersonAppDataRequest('OWNER', 'cfig'), 'data');
req.send(onCheck);
}

function onCheck(){
var owner = gOwner = data.get('owner').getData();
var configData = data.get('data').getData();
var json = configData[owner.getId()]['cfig'];
}

This fails at json. If I use "viewer" instead of "owner" as described
in the code above, the correct value is available in the variable
json.
Could anyone tell me what I am not doing right in the second code
snippet? I am trying to use the code in the canvas view.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Orkut Developer Forum" group.
To post to this group, send email to opensocial-orkut@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/opensocial-orkut?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to