Opened 12 years ago

Closed 12 years ago

#4238 closed defect (fixed)

dijit.Tree violates the dojo.data API.

Reported by: Jared Jurkiewicz Owned by: bill
Priority: high Milestone: 1.0
Component: Dijit Version: 0.9
Keywords: Cc: Dustin Machi
Blocked By: Blocking:

Description

The dijit.Tree widget is violating the dojo.data API and is failing with some stores because of it. This can easily be seen in the demo example:

dojox/data/demos/demo_MultiStores.html

dijit._tree.Controller, on line 28:

if the store supports Notification, subscribe to the notifcation events if (this.store._featuresdojo.data.api.Notification?){

dojo.connect(this.store, "onNew", this, "onNew"); dojo.connect(this.store, "onDelete", this, "onDelete"); dojo.connect(this.store, "onSet", this, "onSet");

}

The widget is accessing internal properties. _features is not an exposed property of the dojo.data API and access in this manner is invalid (and does break). The propery way to access the featureset a store implements is via the getFeatures() function, as defined in: dojo.data.api.Read, and in documentation:

http://www.dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/what-dojo-data/dojo-data-design/read-api

Attachments (1)

dijit._tree.Controller_20070820.patch (604 bytes) - added by Jared Jurkiewicz 12 years ago.
Patch for _tree/Controller.js for problem with getFeatures API

Download all attachments as: .zip

Change History (6)

comment:1 Changed 12 years ago by Jared Jurkiewicz

The more proper manner to be looking up features is:

if the store supports Notification, subscribe to the notifcation events if (this.store.getFeatures()dojo.data.api.Notification?){

dojo.connect(this.store, "onNew", this, "onNew"); dojo.connect(this.store, "onDelete", this, "onDelete"); dojo.connect(this.store, "onSet", this, "onSet");

}

And there are other problems still. It assumes that all stores implement the Identity API, which is not true.

The code which does the binding should be checking to see if that feature is supported as well.

Basically, because of the dojo.data API violations, the only store Tree is going to work with is ItemFileReadStore?. None of the dojox.data stores work anymore and this breaks almost all the demos in dojox/data/demos as well that showed using datastores with widgets. :-(

comment:2 Changed 12 years ago by Jared Jurkiewicz

Well, it at least breaks the MultiStore? widgets one, where I demonstrated using different data stores with Tree and ComboBox? and how that they 'just worked'.

Changed 12 years ago by Jared Jurkiewicz

Patch for _tree/Controller.js for problem with getFeatures API

comment:3 Changed 12 years ago by Adam Peller

Cc: Dustin Machi added
Owner: set to bill

comment:4 Changed 12 years ago by Jared Jurkiewicz

(In [10316]) Fixing problem with internal property access. refs #4238

comment:5 Changed 12 years ago by bill

Resolution: fixed
Status: newclosed

The remaining issue is with getIdentity(), but it's not a bug per se. Tree just requires a store that implements getIdentity(). Might be able to avoid that requirement for read only trees but at this point I don't see a reason to complicate the tree code in that way.

Note: See TracTickets for help on using tickets.