Since the persistence of preferences is not something that is part of Shindig but something your team wrote it is kind of hard for us on the dev list to help you out. Or maybe you question is with regards to something specific in Shindig and I am not understanding you ;)
On Thu, Oct 24, 2013 at 3:52 PM, Darren Bond <db...@globalcad.com> wrote: > Hi Ryan, > > Yes. When we save and restore just the user editable preferences (ENUM, > STRING. LIST, BOOL) everything works well. However, if we then introduce > hidden metadata preferences and try and save them together with the user > editable preferences, only the hidden preferences get saved and restored. > For some, attempting to save both the user preferences and hidden prefs has > the effect of stopping the user preferences from getting persisted? > > Kind regards, > > Darren > > > -----Original Message----- > From: Ryan Baxter [mailto:rbaxte...@apache.org] > Sent: 24 October 2013 14:44 > To: dev@shindig.apache.org > Subject: Re: Maintaining Hidden Prefs - Alongside UserPrefs > > The problem you are having is not really clear to me. It sounds like > when setPreference is called it is overriding the currently saved > preferences, is that correct? > > On Thu, Oct 24, 2013 at 2:59 AM, Darren Bond <db...@globalcad.com> wrote: >> Dear All, >> >> >> >> In accordance with the OpenSocial Tutorials I've implemented User >> Preferences saving/restoring state i.e. those that belong to the range of >> pre-defined types: (ENUM, STRING. LIST, BOOL). However, I'm not currently >> able to also maintain the state of the gadget's HIDDEN user preferences, >> received from metadata. >> >> >> >> The code below renders gadget using its preferences. >> >> >> >> CommonContainer.renderGadget = function (gadget, contentHolder, >> userPreference) { >> var gadgetURL = gadget.Url; >> // going to hardcode these values for width. >> var el = $(contentHolder).get(0); >> var params; >> if (userPreference == null) { >> params = { userPrefs: cacheDefaultUserPreference[gadgetURL] }; >> } else { >> params = { userPrefs: userPreference }; >> } >> params["view"] = "home"; >> if (gadget.viewType == GadgetViewTypes.Canvas) { >> params["view"] = "canvas"; >> } >> params[osapi.container.RenderParam.WIDTH] = '100%'; >> var gadgetSite = CommonContainer.newGadgetSite(el); >> CommonContainer.navigateGadget(gadgetSite, gadgetURL, {}, params); >> defaultUserPreference = {}; >> return gadgetSite; >> }; >> >> >> >> Maintaining the user preferences which are not HIDDEN type works well okay >> and settings are retained by the gadget. However, if I try to do a similar >> action regarding HIDDEN preferences then it appears to have the effect of >> replacing the default gadget's settings and saving just my values that I >> maintained by catching 'set_prefs' event. My callback function looks like >> this... >> >> >> function setPrefs(t, name, value) { >> var info = $('#' + this.f).parent().parent(); >> >> var hfGdgets = $('input[id*=hfGadgetInfo]', info).val(); >> var gadgetInfo = eval("(" + hfGdgets + ")"); >> var cookieUserGadget = new CookieUserGadget(); >> cookieUserGadget.ID = gadgetInfo.CategoryGadgetID; >> cookieUserGadget.GadgetID = gadgetInfo.GadgetID; >> // set Pref in pref dialog >> $("#" + name, info).val(value); >> if (gadgetInfo.UserPreference.Value == null) { >> gadgetInfo.UserPreference.Value = new Object(); >> gadgetInfo.UserPreference.Value[name] = value; >> } else { >> if (typeof gadgetInfo.UserPreference.Value !== 'object') { >> gadgetInfo.UserPreference.Value = eval("(" + >> gadgetInfo.UserPreference.Value + ")"); >> } >> gadgetInfo.UserPreference.Value[name] = value; >> } >> cookieUserGadget.UserPreference = { "Value": >> JSON.stringify(gadgetInfo.UserPreference.Value) }; >> $('input[id*=hfGadgetInfo]', info).val(JSON.stringify(gadgetInfo)); >> var data = { >> "cookieUserGadgetPreference": JSON.stringify(cookieUserGadget) >> }; >> $.ajax({ >> url: '/Channel.aspx/SaveUserGadgetPreference', >> dataType: 'json', >> type: "post", >> data: JSON.stringify(data), >> contentType: "application/json; charset=utf-8", >> async: false, >> success: function (data) { >> } >> }); >> } >> >> >> >> Examples of gadgets with internal HIDDEN preferences include:- >> >> Google News (http://www.google.com/ig/modules/tabnews/tabnews.xml) >> >> Date & Time (http://gadgets.blueg.com/standard/date-time/date-time.xml) >> >> >> >> Examples of gadgets with user preferences include:- >> >> Dictionary > (http://www.gstatic.com/ig/modules/dictionary/dictionary_v2.xml) >> >> Gismeteo >> (http://sterno-gadgets.googlecode.com/svn/trunk/gismeteo/gismeteo.xml) >> >> >> >> My question is this - how to correctly retain the internal gadget's state >> between the requests and not to erase the rest of its user preference >> settings? >> >> >> >> Any help much appreciated. >> >> >> >> Kind regards, >> >> >> >> Darren >> >> >> > >