Hi Paul, It's working fine now...all that was to be done was doin the 'get'.
Thks a lot.. On Mar 8, 2:03 pm, Paul Kinlan <[email protected]> wrote: > Hi, > > Thanks for providing the extra information. > > A quick answer is yes, you will need to do the prefs.get and assign it. > Currently you are stashing it in the user prefs, but you are not assigning > that value anywhere when you are showing the alert box. > > The UserPref configuration appears correct. I am still not convinced that > your callback is doing the correct thing. > > You would have do something along the lines of: > > nument=data.num_entries > alert("nument is " + nument + "."); > prefs.set("num_entries",nument); > num_entries = prefs.getInt("num_entries"); > alert("num_entries is " + num_entries + "."); > > It is only doing the get, to get it out of the user preferences as you > already have the variable from the json object in the current scope. > > P > > > > On Mon, Mar 8, 2010 at 6:31 AM, aslum <[email protected]> wrote: > > Hi Paul, > > > Thanks for ur reply...this is the xml...i took this from one of the > > tutorials and working upon it > > > Since i'm doin pref.set() do i have to do prefs.get()?? > > > <?xml version="1.0" encoding="UTF-8" ?> > > <Module> > > <ModulePrefs title="Fetch Feed Example--parse2" > > > <Require feature="opensocial-0.8" /> > > <Require feature="views" /> > > <Require feature="setprefs"/> > > </ModulePrefs> > > <UserPref name="show_date" display_name="Show Dates?" > > datatype="bool" default_value="false"/> > > <UserPref name="num_entries" datatype="hidden"/> > > <UserPref name="show_summ" display_name="Show Summaries?" > > datatype="bool" default_value="false"/> > > <Content type="html" view = "home,canvas"> > > <![CDATA[ > > <style> #content_div { font-size: 80%; margin: 5px; background- > > color: #FFFFBF;} </style> > > <div id="content_div"></div> > > <script language="JavaScript" src="http://jsonfeed.googlecode.com/ > > files/jsonparse.js"></script> > > <script type="text/javascript"> > > // Get userprefs > > var prefs = new gadgets.Prefs(__MODULE_ID__); > > var showdate = prefs.getBool("show_date"); > > var num_entries; > > var summaries = prefs.getBool("show_summ"); > > function getFeed() { > > var params = {}; > > makeJSONRequest(); > > params[gadgets.io.RequestParameters.CONTENT_TYPE] = > > gadgets.io.ContentType.FEED; > > params[gadgets.io.RequestParameters.NUM_ENTRIES] = new > > Number(num_entries); > > alert("The stored entry is " + num_entries + "."); > > params[gadgets.io.RequestParameters.GET_SUMMARIES] = summaries; > > var url = "http://rss.msnbc.msn.com/id/3663447/device/rss/ > > default.xml"; > > gadgets.io.makeRequest(url, response, params); > > }; > > function makeJSONRequest() { > > alert("1 is called"); > > var params = {}; > > params[gadgets.io.RequestParameters.CONTENT_TYPE] = > > gadgets.io.ContentType.JSON; > > // This URL returns a JSON-encoded string that represents a > > JavaScript object > > var url = "http://jsonfeed.googlecode.com/files/jsonentry.txt"; > > gadgets.io.makeRequest(url, callback, params); > > }; > > function callback(obj) { > > alert("2 is called"); > > var jsondata = obj.data; > > nument=jsondata.parseJSON(); > > alert("nument is " + nument + "."); > > prefs.set("num_entries",nument); > > alert("num_entries is " + num_entries + "."); > > }; > > function response(obj) { > > // obj.data contains the feed data > > var feed = obj.data; > > var html = ""; > > > // Display the feed title and description > > html += "<div><b>" + feed.Title + "</b></div>"; > > html += "<div>" + feed.Description + "</div><br>"; > > > // Access the data for a given entry > > if (feed.Entry) { > > for (var i = 0; i < feed.Entry.length; i++) { > > html += "<div>" > > + "<a target='_blank' href='" + feed.Entry[i].Link + "'>" > > + feed.Entry[i].Title > > + "</a> "; > > if (showdate==true) > > { > > // The feed entry Date field contains the timestamp in > > seconds > > // since Jan. 1, 1970. To convert it to the milliseconds > > needed > > // to initialize the JavaScript Date object with the correct > > date, > > // multiply by 1000. > > var milliseconds = (feed.Entry[i].Date) * 1000; > > var date = new Date(milliseconds); > > html += date.toLocaleDateString(); > > html += " "; > > html += date.toLocaleTimeString(); > > } > > if (summaries==true) { > > } > > html += "</div>"; > > } > > } > > document.getElementById('content_div').innerHTML = html; > > }; > > gadgets.util.registerOnLoadHandler(getFeed); > > </script> > > ]]> > > </Content> > > </Module> > > > The file jsonentry contains the entry {"num_entries" : "7"}...Please > > let me know if u need more details > > > On Mar 5, 5:17 pm, Paul Kinlan <[email protected]> wrote: > > > Hi, > > > > Can you provide more information about the gadget? For instance, can you > > > provide the Gadget XML so that we can verify that you are using the > > > <UserPref> tag and you have <Required> set prefs. > > > > Also, I can't see it in your code, but I am assuming that you > > > have initialized your prefs variable with the following: > > > > var prefs = new gadgets.Prefs(); > > > > Additionally you are alerting the variable "num_entries" but that is not > > > defined or set anywhere either in your example. You would have to do > > > something along the lines of: > > > > var num_entries = prefs.get("num_entrie"); > > > > More information can be found athttp:// > > code.google.com/apis/gadgets/docs/fundamentals.html#Datatypes > > > > Thanks, > > > Paul > > > > On Fri, Mar 5, 2010 at 11:34 AM, aslum <[email protected]> wrote: > > > > Hi, > > > > > I am trying to take a user preference value thru jason....But i am > > > > facing problem in saving the set pref.set..its not storing..It will be > > > > greatly helpful...if anyone can tell me wats the pbm > > > > > function makeJSONRequest() { > > > > alert("1 is called"); > > > > var params = {}; > > > > params[gadgets.io.RequestParameters.CONTENT_TYPE] = > > > > gadgets.io.ContentType.JSON; > > > > // This URL returns a JSON-encoded string that represents a > > > > JavaScript object > > > > var url = "http://jsonfeed.googlecode.com/files/jsonentry.txt"; > > > > gadgets.io.makeRequest(url, callback, params); > > > > }; > > > > function callback(obj) { > > > > alert("2 is called"); > > > > var jsondata = obj.data; > > > > for (var key in jsondata){ > > > > var nument = jsondata[key]; > > > > } > > > > alert("nument is " + nument + "."); > > > > prefs.set("num_entries",nument); > > > > alert("num_entries is " + num_entries + "."); > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "iGoogle Developer Forum" group. > > > > To post to this group, send email to > > [email protected]. > > > > To unsubscribe from this group, send email to > > > > [email protected]<google-gadgets-api%2bunsubs[email protected]> > > <google-gadgets-api%2bunsubs[email protected]> > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/Google-Gadgets-API?hl=en.-Hide quoted > > text - > > > > - Show quoted text - > > > -- > > You received this message because you are subscribed to the Google Groups > > "iGoogle Developer Forum" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<google-gadgets-api%2bunsubs[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/Google-Gadgets-API?hl=en.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "iGoogle Developer Forum" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/Google-Gadgets-API?hl=en.
