You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Yong Li <sd...@gmail.com> on 2010/06/13 15:46:06 UTC

Questions about the user prefs storage

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

Re: Questions about the user prefs storage

Posted by Yong Li <sd...@gmail.com>.
Hello Justin,

I did not know how to use the callback function in the prefs save
functions. I found www.igoogle.com does not use callback function when
the gadgets are saving prefs data. It just send a GET request to the
server. If there is any network connection error, the data will be
lost(You can disconnect the network cable and save data for a test)

Regarding the restore user prefs issue, if the browser sends a reqest
to /metadata, the servelet will process the user prefs and append them
to the IframeUrl string. browser javascript functions can use the
string to get all the current user prefs data.

If the saved user prefs are appended to the IframeUrl string, I think
the server side does not need to save them in the prefs JSON string.

You mentioned the GadgetFactory, is it the PHP version? I am using the
JAVA version.


I found there is a JsonDbOpensocialService in the shindig, We may use
the SPI to save/restore user prefs data. However, I do not know the
process. I am working on it now.

Yong


在 2010年6月16日 UTC+8下午4时33分21秒,Justin Wyllie <ju...@hotmail.co.uk> 写道:
>
> 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: sdliyong@gmail.com
>> Date: Wed, 16 Jun 2010 15:16:50 +0800
>> Subject: Re: Questions about the user prefs storage
>> To: dev@shindig.apache.org
>>
>> 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 <ju...@hotmail.co.uk>:
>> >
>> > 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: sdliyong@gmail.com
>> >> To: dev@shindig.apache.org
>> >>
>> >> 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

RE: Questions about the user prefs storage

Posted by Justin Wyllie <ju...@hotmail.co.uk>.
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: sdliyong@gmail.com
> Date: Wed, 16 Jun 2010 15:16:50 +0800
> Subject: Re: Questions about the user prefs storage
> To: dev@shindig.apache.org
> 
> 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 <ju...@hotmail.co.uk>:
> >
> > 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: sdliyong@gmail.com
> >> To: dev@shindig.apache.org
> >>
> >> 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

Re: Questions about the user prefs storage

Posted by Yong Li <sd...@gmail.com>.
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 <ju...@hotmail.co.uk>:
>
> 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: sdliyong@gmail.com
>> To: dev@shindig.apache.org
>>
>> 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

RE: Questions about the user prefs storage

Posted by Justin Wyllie <ju...@hotmail.co.uk>.
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: sdliyong@gmail.com
> To: dev@shindig.apache.org
> 
> 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