<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'dojo data chapter examples not working' | Pragmatic Forums</title>
    <link>http://forums.pragprog.com/forums/58/topics/351</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>dojo data chapter examples not working posted by Craig Riecke @ Sun, 07 Sep 2008 19:25:41 -0000</title>
      <description>&lt;p&gt;We did Q/A, but unfortunately just a bit too early.  Part of the release process for the code was to add the boilerplate copyright notices to each file.  We didn&amp;#8217;t think to do Q/A after that &amp;#8211; after all, it&amp;#8217;s just a comment, right?  Turns out this confuses Dojo in a few places simply because some files that look like code are in fact data.  &lt;span class="caps"&gt;JSON&lt;/span&gt; is a perfect example.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ll try to get this into the Q/A process for Pragmatic Books in general.&lt;/p&gt;</description>
      <pubDate>Sun, 07 Sep 2008 19:25:41 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:58:351:4452</guid>
      <author>Craig Riecke</author>
      <link>http://forums.pragprog.com/forums/58/topics/351</link>
    </item>
    <item>
      <title>dojo data chapter examples not working posted by Don Albertson @ Thu, 04 Sep 2008 15:22:29 -0000</title>
      <description>&lt;p&gt;This chapter needed a Q/A team to validate it.  So far, with 2 titles that I&amp;#8217;ve purchased I&amp;#8217;m deeply disappointed in the Pragmatic series.  Neither one would qualify as a shippable product.&lt;/p&gt;</description>
      <pubDate>Thu, 04 Sep 2008 15:22:29 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:58:351:4424</guid>
      <author>Don Albertson</author>
      <link>http://forums.pragprog.com/forums/58/topics/351</link>
    </item>
    <item>
      <title>dojo data chapter examples not working posted by David Wilhelm @ Thu, 03 Apr 2008 16:35:15 -0000</title>
      <description>&lt;p&gt;just noticed something else&lt;/p&gt;


	&lt;p&gt;the final &amp;#8216;null&amp;#8217; value in the genetox dataset is also causing problems because it is not handled by ItemFileReadStore, which tries to add it as an item. Around line 438 in ItemFileReadStore.js &lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;for(i = 0; i &amp;lt; this._arrayOfTopLevelItems.length; ++i){
}&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;item = this._arrayOfTopLevelItems[i];
if(!item) continue;
addItemAndSubItemsToArrayOfAllItems(item);
item[this._rootItemPropName]=true;&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;I added the line&lt;/p&gt;


	&lt;p&gt;if(!item) continue;&lt;/p&gt;


	&lt;p&gt;to avoid adding null, undefined, or other values which are falsy as items&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;AFAIK&lt;/span&gt; all items should be objects with attributes, which are truthy&lt;/p&gt;</description>
      <pubDate>Thu, 03 Apr 2008 16:35:15 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:58:351:2536</guid>
      <author>David Wilhelm</author>
      <link>http://forums.pragprog.com/forums/58/topics/351</link>
    </item>
    <item>
      <title>dojo data chapter examples not working posted by David Wilhelm @ Thu, 03 Apr 2008 16:03:06 -0000</title>
      <description>&lt;p&gt;Hey&lt;/p&gt;


	&lt;p&gt;I was excited to see the new chapters on dojo.data and dojo.declare.. nice to have a thorough analysis.&lt;/p&gt;


	&lt;p&gt;However I was getting errors with the examples for dojo.data, in particular the ones with the FilteringSelect, that are using the genetox dataset. It was really bothering me, so I dug in to track the bug down&amp;#8230;.&lt;/p&gt;


	&lt;p&gt;I figured out that when the ItemFileReadStore was returning a bunch of items, some were failing the &amp;#8216;isItem&amp;#8217; test and the whole thing blew up with an &amp;#8216;invalid item&amp;#8217; error. I suspected the data source was the cause of the error, so I hacked away at it until the error went away. The error re-appeared whenever there was an item with an attribute which was an object specifically the results attribute:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;results: [ 
  { specimen:"Mouse", 
    result:"Negative" 
  },&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;So I read through the ItemFileReadStore code to see why this was happening. It turns out that when there&amp;#8217;s an item attribute which is an object, it is getting added as an item. However (in this case) these sub-items do not have the specified identifier for the datastore, so these items will fail &amp;#8216;isItem&amp;#8217; when the time comes.&lt;/p&gt;


	&lt;p&gt;This behaviour doesn&amp;#8217;t seem right to me. I don&amp;#8217;t think that all objects in the data set should be added as items, especially if they don&amp;#8217;t have the specified identifier. There is a very easy fix for this&amp;#8230; don&amp;#8217;t add sub-items if they don&amp;#8217;t have the identifier.. around line &lt;br /&gt;396 of ItemFileReadStore, in the function valueIsAnItem(aValue) theres this code:             &lt;br /&gt;var isItem = (
        (aValue != null) &amp;#38;&amp;#38;
        (typeof aValue  "object") &amp;#38;&amp;#38;
        (!dojo.isArray(aValue)) &amp;#38;&amp;#38;
        (!dojo.isFunction(aValue)) &amp;#38;&amp;#38;
        (aValue.constructor  Object) &amp;#38;&amp;#38;
        (typeof aValue._reference  "undefined") &amp;#38;&amp;#38; 
        (typeof aValue._type  &amp;#8220;undefined&amp;#8221;) &amp;#38;&amp;#38; 
        (typeof aValue._value == &amp;#8220;undefined&amp;#8221;)&lt;br /&gt;)&lt;br /&gt;return isItem;&lt;/p&gt;


	&lt;p&gt;now if we add the following to the list of conditions:&lt;/p&gt;


	&lt;p&gt;&amp;#38;&amp;#38;(dataObject.identifier?aValue[dataObject.identifier]:true)&lt;/p&gt;


	&lt;p&gt;this will ensure that subItems without the identifier are not loaded as items (but if there&amp;#8217;s no identifier it just adds it &amp;#8211; not sure if we want this either, but anyways)&lt;/p&gt;


	&lt;p&gt;So that helped get rid of the &amp;#8220;invalid item&amp;#8221; error.&lt;/p&gt;


	&lt;p&gt;But then I was still getting another error which said &amp;#8220;missing parenthetical&amp;#8221;&lt;/p&gt;


	&lt;p&gt;If I removed the comment from the beginning of the json file though, this error went away. The filtering select now works happily. So that was my morning&amp;#8230; but at least I got to the bottom of it. Hope this helps someone else.&lt;/p&gt;


	&lt;p&gt;Dave&lt;/p&gt;</description>
      <pubDate>Thu, 03 Apr 2008 16:03:06 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:58:351:2534</guid>
      <author>David Wilhelm</author>
      <link>http://forums.pragprog.com/forums/58/topics/351</link>
    </item>
  </channel>
</rss>
