#12314 closed enhancement (fixed)
[patch][ccla] MVC support for dijit based on dojo.Stateful
Reported by: | rahul | Owned by: | Chris Mitchell |
---|---|---|---|
Priority: | high | Milestone: | 1.7 |
Component: | DojoX MVC | Version: | 1.6.0b1 |
Keywords: | 1.7-mobile | Cc: | Mark Wubben, ben hockey |
Blocked By: | Blocking: |
Description (last modified by )
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.
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:
- dojo.store 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.
Attachments (3)
Change History (32)
Changed 10 years ago by
Attachment: | images.zip added |
---|
comment:1 Changed 10 years ago by
This ticket should have been an enhancement clearly, but I don't see an option to change it now (from a defect).
comment:2 Changed 10 years ago by
Type: | defect → enhancement |
---|
comment:4 Changed 10 years ago by
I've updated the main patch containing the MVC functionality to include most changes mentioned towards the bottom of the original issue description and some other improvements:
- Added dojo.store support: models can be populated from stores and have commit/reset function.
- The dijit._DataBindingMixin class is now aligned with the dojo.Stateful affinity of the rest of this work.
- There are now some examples that show async loading from stores as well.
- Couple of new tests, an MVC tests runner, numerous code style and miscellaneous improvements.
At this point, I'd consider this patch ready. Feedback welcome.
comment:5 Changed 10 years ago by
Cc: | Mark Wubben added |
---|
comment:6 Changed 10 years ago by
Cc: | ben hockey added |
---|
comment:7 Changed 10 years ago by
I've updated the patch to incorporate most feedback from this thread on the contributors list:
Next up, I intend to look at changes for programmatic dijit instantiations.
comment:8 Changed 10 years ago by
Keywords: | 1.7-mobile added; MVC removed |
---|
comment:9 Changed 10 years ago by
The latest patch incorporates most feedback from before-mentioned thread on contributors list. I think the code is ready for another look. Thanks in advance for the feedback :-)
comment:11 Changed 10 years ago by
Milestone: | tbd → 1.7 |
---|
comment:13 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:14 Changed 10 years ago by
Ported the MVC support to a dojox.mvc project, based on prior discussions on the topic. This addresses some, but not all, feedback received 3-odd weeks back. Will respond in more detail on list when time permits.
For this patch / version, the following folks have also helped with the move to dojox.mvc and other tasks: Ed Chatelain and Akira Sudoh.
comment:15 Changed 10 years ago by
Component: | Dijit → Dojox |
---|---|
Owner: | set to Adam Peller |
comment:16 Changed 10 years ago by
Owner: | changed from Adam Peller to Chris Mitchell |
---|
Changed 10 years ago by
Attachment: | dojox.mvc.zip added |
---|
MVC support based on dojo.Stateful, with minor updates.
comment:17 Changed 10 years ago by
comment:18 Changed 10 years ago by
rahul, please go through all test files and convert spaces to tabs. next time, ensure that all files use tabs for spacing, and have consistent EOL chars. several files did not follow style guidelines and had to be fixed.
comment:20 Changed 10 years ago by
Thanks, ack'ed whitespace issues in tests, will clean up in subsequent patch(es).
Could you also check in mvc.js in dojox/trunk? Didn't see that go through in r24670; its in the attached zip and needs to be checked in.
comment:21 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Changed 10 years ago by
Attachment: | dojox-mvc.patch added |
---|
Various improvements; patch rooted at dojox trunk.
comment:22 Changed 10 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Attaching a patch with various improvements made to dojox.mvc over the last few days. Includes my changes and changes made by Ed Chatelain (for included mobile demos etc.).
Please apply before release tag, thanks in advance.
comment:23 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:25 Changed 10 years ago by
comment:26 Changed 10 years ago by
comment:27 Changed 10 years ago by
comment:28 Changed 10 years ago by
comment:29 Changed 10 years ago by
Component: | Dojox → DojoX MVC |
---|
Binary resources (images) used in demos included in the patch.