« Return to Thread: data store

Re: data store

by Vance Dubberly :: Rate this Message:

Reply to Author | View in Thread

Dustin,
  I really do appreciate the explanation of data stores it is both
insightful and honest. Understanding the philosophy of why a thing is
architected the way it is goes a long way toward making it work and it
sounds like the theory is good, even if the implementation is lacking.

  The downside of course is that I'm still left writing my own
datastore as at least instantiating dojo.data.ItemFileReadStore with
the aforementioned JSON results in a data store with no data. :(

  I do think I've a new Tagline for dojo.  "Making the complex,
attainable and the simple impossible." :)  ( wasn't the Java credo for
a long time? )  I can do things with dojo I never thought possible and
yet the simple stuff leaves me totally screwed.

Anyway I gave up and just used an old fashioned select box.  Looks
like crap but it does the job.

Vance






On Dec 13, 2007 1:17 PM, Dustin Machi <dmachi@...> wrote:

> I agree that lots of work still needs to be done on making use of stores
> easier and more robust.  Right now it can be too difficult to use in
> what are simple case. However...
>
> > Honestly I don't want to use a datastore to do it.  Seems like a
> > complete waste of memory and CPU.
>
> The fact is regardless of whether or not you have to declare a store or
> even if a widget actually uses something called a store, you are using
> one.  This doesn't necessarily mean a dojo.data store, but every widget
> that visualizes some data set must be able to have access to a data set
> that it understands how to access and view and potentially to manipulate
> as well.
>
> In the previous versions of dojo each widget handled its data on its
> own.  This of course led to problems that the particular data set that
> they knew how to manage didn't quite match up with what the user needed
> or wanted.  Or they needed to be retrieved from the server in a lazy
> loaded way.  Or lazy loading work, but not in the way that a particular
> dev needed it to work.  dojo.data does nothing more than split that
> functionality outside of the widget so stores could be defined in some
> standard way that lets the developers write whatever code they might
> like to access their server data, but still provides widgets a common
> interface so they don't have to be rewritten, extended or whatever with
> each new use case.
>
> Now, bugs aside and not withstanding some adjustments that might be
> needed to the dojo.data api's themselves, using stores should ultimately
> reduce the number of instances of a piece of data because one store can
> be used by multiple widgets.  It ultimately also requires less widget
> code to be written and downloaded.
>
> > However not using a datastore  does
> > not appear to be an option.
>
> Actually in some cases this is already the case, but as mentioned above
> is only illusory. For example, the combobox widget can take normal
> <option> tags as children.  However what happens in reality is that the
> widget will then ingest that data and create the store on its own.
> Having capabilities like this available across the full set of widgets
> that use dojo data would go along way towards making some of the simple
> cases simpler.  (
>
> *on a side note for lurkers: I would say however that widgets that do
> this should not automatically dojo.require() the store type they want to
> use as you then have to get that code/store even if you don't want to
> use it and that can be expensive.  I would prefer it to just throw an
> error if you tried to use a widget in this way and hadn't included an
> appropriate store.  It would also be preferable to allow usage like this
> to specify which type of store would be created by default, though this
> might not be practical in some circumstances.  Doing this allow
> automatic creation, but if the rest of the app is using a different
> store type, it doesn't require that store to be loaded.)
>
>  So baring that, I want to populate a
> > datastore with the above object without having to read it from the
> > server.  I already have the data it was pulled from the server in a
> > much more complex format and is being used for may things. the above
> > sample is a derived subset of that data.
> >
> > what I'd love to do is this:
> >
> > dijit.form.FiteringSelect.store = pageJSON;
> >
>
> This won't work because that is passing a js object in and the filtering
> select would be expecting that to be a store instance, not a js object.
>
> > baring that I'd like to do this:
> >
> > store = new dojo.data.SomeKindOfStore( pageJSON )
> > dijit.form.FilteringSelect.store = store;
> >
>
> This in general is correct, however i think in practical terms that
> right now most data using widgets expect to have a store at creation
> time.  So your stores would need to be created before the widget was
> instantiate.
>
> > What I don't want to do is go to the server for data I already have.
> >
> You don't have to go to the server for the data you already have.
> ItemFileReadStore takes a set of data, formatted in its special way, and
> makes it available locally.  You could create your stores right at the
> beginning of your app for example (not in addOnLoad() and before the
> <body>) and that store could be avialable to anything  you either markup
> or programmatically create later.
>
>
> Dustin
>
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest@...
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>



--
To pretend, I actually do the thing: I have therefore only pretended to pretend.
  - Jacques Derrida
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://dojotoolkit.org/mailman/listinfo/dojo-interest

 « Return to Thread: data store