You will have to store this as a JSON-encoded string since the
persistence store can only contain string values. The gadgets.util
library includes functions for encoding a JavaScript data structure as
a string and parsing this string back into the JavaScript object:

// Convert to JSON string:
var myArray = ['value1', 'value2', 'value3'];
var jsonString = gadgets.json.stringify(myArray);

// Convert from JSON string:
var myArrayReloaded = gadgets.json.parse(jsonString);
myArrayReload.push('value4');

Here is the API reference page:
http://code.google.com/apis/opensocial/docs/0.7/reference/gadgets.json.html

Cheers!
- Jason

On Jun 24, 6:02 pm, "Vini..." <[EMAIL PROTECTED]> wrote:
> hm...
> I want to register multiple values in a key type:
>
> key = (value1, value2, value3, ...)
>
> how do this? I can give an example?
>
> On Jun 24, 5:37 pm, Jason <[EMAIL PROTECTED]> wrote:
>
> > Your requestData and handleRequestData functions look OK but your
> > AddData function looks off.
>
> > Since you didn't provide the rest of your application, I have to
> > assume that "input_comm" is the ID of an HTML text input -- thus,
> > taking the value of the input, which is fine. The key that you're
> > using won't work, however, since it's always undefined. This value
> > needs to be a string (e.g. 'thefield' as you use in requestData). Once
> > you make this fix, your sample should be much closer to working.
>
> > In the future, please provide a better explanation of the problem.
> > "It's not working" is not as helpful as reporting any errors or
> > incorrect output you see, etc. Thanks.
>
> > - Jason
>
> > On Jun 23, 10:37 pm, Vinicius <[EMAIL PROTECTED]> wrote:
>
> > > what is wrong in the code?????? not running this ... I tried this
> > > code ... use array pra register several keys dynamically and their
> > > values , help me plis !!!
>
> > >   <script type="text/javascript">
> > >         gadgets.util.registerOnLoadHandler(requestData);
>
> > >    var htmlout = "";
> > >    var me = null;
>
> > >    function AddData() {
> > >      var req = opensocial.newDataRequest();
> > >      var palavras = document.getElementById("input_comm").value;
> > >      var thefield = [];
>
> > > req.add(req.newUpdatePersonAppDataRequest("VIEWER",
> > > thefield[thefield.length], palavras));
> > >           req.send(requestData);
> > >    }
>
> > >    function requestData() {
> > >      var req = opensocial.newDataRequest();
> > >      var fields = [ "thefield" ];
>
> > > req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER),
> > > "viewer");
> > >      req.add(req.newFetchPersonAppDataRequest("VIEWER", fields),
> > > "viewer_data");
> > >      req.send(handleRequestData);
> > >    }
>
> > >    function handleRequestData(data) {
> > >      var mydata = data.get("viewer_data");
> > >      var viewer = data.get("viewer");
> > >      me = viewer.getData();
>
> > >      if (mydata.hadError()) {
> > >        htmlout += data.getError();
> > >        return;
> > >      }
> > >      // Do something with the returned data - note the getData call
> > >      doSomethingWithData(mydata.getData());
> > >    }
>
> > >    function doSomethingWithData(data) {
> > >      //Data is indexed by user id, and represents an object where
> > > keys
> > >      //correspond with the app data fields.
> > >      var mydata = data[me.getId()]["thefield"];
>
> > >           document.getElementById('content_div').innerHTML +=
> > > mydata[mydata.length] + "<br />";}
>
> > >  </script>
--~--~---------~--~----~------------~-------~--~----~
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