Opened 11 years ago

Last modified 11 years ago

#12314 closed enhancement

[patch][ccla] MVC support for dijit based on dojo.Stateful — at Initial Version

Reported by: rahul Owned by:
Priority: high Milestone: 1.7
Component: DojoX MVC Version: 1.6.0b1
Keywords: 1.7-mobile Cc: Mark Wubben, ben hockey
Blocked By: Blocking:


As background, we discussed MVC (Model-View-Controller) enhancements to Dojo late last year on the contributors list and also presented it to a few folks at DDD in October.

An old resource (out of date code, URL may become defunct), with further background and pointers, in case it serves as a reminder for those who've seen this, is here:

We now have the code ready to propose this addition for dijit (patches forthcoming).

Most of the base MVC functionality is provided by two new classes:

  • dijit.StatefulModel - The JavaScript model on the client, takes plain JavaScript object input.
  • dijit._DataBindingMixin - The mixin that enables dijits to have the declarative data binding specification capability ("ref" attribute or data-dojo-props property).

The class docs in the patch have lot more details.

Then there are three new MVC container widgets (plus a base class) building on base functionality above as follows:

  • dijit.mvc._Container - Base class for most MVC containers.
  • dijit.mvc.Group - Container that enables data binds for hierarchical data.
  • dijit.mvc.Repeat - Container that enables data binds for repeating data i.e. arrays.
  • dijit.mvc.Generate - Container that generates its view based on data its bound to.

The two small changes to existing files are to ensure that those dijits consult model or bind validity before determining the response to isValid().

In addition, there are a number of demos in the tests/ directory, corresponding new doh and robot tests along with an index page for demos and some new demo resources (stylesheets, images, json files).

It seemed best to get the patch out now, though the following incremental updates are planned over the next week or two:

  • support - Loading model input from stores and commiting model changes.
  • dojo.Stateful-ness of dijit._DataBindingMixin - The API needs to be better aligned with dojo.Stateful i.e. get("binding") instead of getBinding() etc.
  • Duplication in dijit.mvc._Container - Two private methods are copied for dijit._Templated, there may be a way to avoid that with some more thought.
  • <script>s in demo html files instantiating the model currently assume synch for simplicity.

The original authors of this body of work are Rahul Akolkar (me) and Charlie Wiecha. We have been joined by Ed Chatelain this year (the tests come from Ed, for example). This patch is covered by the IBM CCLA. We also showed this work to Bill and Doug last week and have incorporated some of their initial feedback into the patch.

As always, feedback is much appreciated.

Change History (1)

Changed 11 years ago by rahul

Attachment: added

Binary resources (images) used in demos included in the patch.

Note: See TracTickets for help on using tickets.