I have a template that I am now using client side processing (thanks
Lev) to output.  I am making opensocial data requests to retrieve data
and then render into the template.  When I try to process App Data,
however, there is no way to represent data for a single person using
opensocial templates.

 

Here is an example of what I am doing:

 

<script type="text/os-template" name="basictemplate"
xmlns:os=http://ns.opensocial.org/2008/markup>

                <div>Owner id is ${ownerinfo.displayName}</div>

                <div>Owner data key=key1 value=${ownerdata.2.key1}</div>

</script>

 

<div id="renderhere"></div>

 

<script type="text/javascript">

                function getData()

                {

                                var req = opensocial.newDataRequest();

 
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER),
'ownerinfo');

 
req.add(req.newFetchPersonAppDataRequest(opensocial.newIdSpec({userId :
'OWNER'}), 'key1'), 'ownerdata');

                                req.send(render);

                }

 

                function render(data)

{

                var basicTemplate =
opensocial.template.getTemplate('basictemplate');

 
basicTemplate.renderInto(document.getElementById("renderhere"), data);

                gadgets.window.adjustHeight();

                }

 

                gadgets.util.registerOnLoadHandler(getData);

</script>

 

The request returns a JSON dataset that looks like this:

 

[{"id":"ownerinfo","data":{"id":"1","name":{"formatted":"Steve
Here"},"displayName":"Steve"

}},{"id":"ownerdata","data":{"1":{"key3":"value3","key4":"value4","key1"
:"value1","key2":"value2"

}}}]

 

Owner info displays fine in the opensocial template, but notice the App
Data for the owner it has the person id in the middle, so within the
opensocial template I have to refer to it this way ${ownerdata.2.key1}.
Does anyone know another way of doing this, obviously the "2" in the
middle is no good.  Am I requesting the data wrong?

 

Any help would be appreciated.

 

Steve T.

Reply via email to