Hi Yong
How are you going to get them from the client (I take it you mean browser) into
the Userprefs object in the gadget?
I think you may find you can get them straight into the UserPrefs object by
doing something in GadgetFactory. It seems to me that this class is used by
both the gadget rendering call and the metadata call so doing it here will mean
that they end up on both the metadata (both on the iframeUrl field in the
metadata and the UserPrefs object) and in the gadget. It looks like they are
injected into the gadget by inserting a line like this:
gadgets.Prefs.setDefaultPrefs_({"name":"freddy","coke_pepsi":"coke","followup":"yes","fav_foods":"","diet":""});
at the end of all the other Javascript injection.
Anyway I'd be interested to know how you solve it.
Did you solve the first problem about gadgets.io.makeNonProxiedRequest and a
callback?
We're just using Ajax (were on the same domain) to make the call to save the
prefs.
Cheers
Justin
> From: [email protected]
> Date: Wed, 16 Jun 2010 15:16:50 +0800
> Subject: Re: Questions about the user prefs storage
> To: [email protected]
>
> Hi Justin,
>
> Thank you for your update.
>
> I found we can add some userprefs data in the Rpcservlet for the
> metadata request. the new added user prefs will be appended in the
> iframeUrl string. the client can get them and add the data to the
> Useprefs object using the javascript functions.
>
> I will check the GadgetFactory class you mentioned.
>
> Thank you again!
>
> Yong
>
> 2010/6/14 Justin Wyllie <[email protected]>:
> >
> > Hi Yong
> > With respect to your second question. I have the same question.
> > So far: I have found in the GadgetFactory class two methods
> > addSubstitutions and applySubstitutions. This class is used by
> > MetadataHandler which handles the metadata request. It looks to me like
> > this is the point where one should apply the substitutions to restore the
> > user's preferences. The GadgetFactory class has the gadget url available as
> > $this->context->getUrl(); and the token as $this->token assuming the
> > service was called with a token, so one could use these to access the
> > stored values I guess.
> > This is what I'm planning to do but to be honest I'm not 100% sure. I'm
> > fumbling around in the dark a little.
> > Hope that helps even a little bit.
> > Justin
> >
> >
> >
> >
> >
> >
> >
> >>
> >> Date: Sun, 13 Jun 2010 21:46:06 +0800
> >> Subject: Questions about the user prefs storage
> >> From: [email protected]
> >> To: [email protected]
> >>
> >> Hello All,
> >>
> >> I want to store the gadgets user prefs on the web server side.
> >> Currently, there is a cookie-based storage for demo. I want to replace
> >> the save/read to cookie functions in saveprefs/getprefs, for example,
> >> use the gadgets.io.makeNonProxiedRequest functions to post the data to
> >> a servlet, then save the data to a database. However, I do not know
> >> how to handle the callback functions. If there is any network
> >> connection error, the getPrefs/savePrefs functions do not know if the
> >> call is OK.
> >>
> >> Another question, how to restore these user prefs data? during the
> >> metadata request, there is no user-defined data, only the default
> >> value, Can I modify the rpcservlet process function to add the
> >> user-defined value in the gadget json array, then return to the
> >> client?
> >>
> >> Thanks a lot !
> >>
> >> Yong
> >
> > _________________________________________________________________
> > http://clk.atdmt.com/UKM/go/197222280/direct/01/
> > We want to hear all your funny, exciting and crazy Hotmail stories. Tell us
> > now
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
Do you have a story that started on Hotmail? Tell us now