Hi People. First off I want to make it known that I am completely new to opensocial, and web development in general.
I am trying to build a simple application that supplies the user with dynamically generated information from a servlet using their displayname. The servlet works and all opensocial script runs fine on the first page, but when the servlet returns the results page the code does not work and no longer is able to access the basic user details. The only information i am trying to gain is the myspace viewer name. My javascript code is below.
Please help as I am baffled and pretty sure this is not a bug but is due to my own lack of experience.
Thanks
/////////////////////////////////////////
function init()
{
var container = opensocial.Container.get();
var dataRequest = container.newDataRequest();
//Create a request for the viewer's friends
var friendRequest = dataRequest.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS);
//Create a request for the viewer name
var personRequest = dataRequest.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER);
//Add the requests for processing.
dataRequest.add(friendRequest);
dataRequest.add(personRequest);
//Send the request, passing in a callback.
dataRequest.send(responseCallback);
}
function responseCallback(dataResponse)
{
friendsData = dataResponse.get(opensocial.DataRequest.Group.VIEWER_FRIENDS).getData();
viewer = dataResponse.get(opensocial.DataRequest.PersonId.VIEWER).getData();
viewerName = viewer.getDisplayName();
document.getElementById('greet').innerHTML += viewerName;
}
init();
/////////////////////////////////////////