Prototypes |
It's been a while since I last blogged about my experiments with Rails and the Dojo Toolkit. In fact, since that last blog post, I've migrated the Rails development environment to work against dojo-trunk by regularly performing a Subversion Update within my environment. Overall progress thus far include the following: Modified the Rich Text Editor widget The Rich Text Editor was also enhanced to expand to the full dimensions of its parent container, instead of the default behavior requiring you to specify a pixel-height.
Created a new Dojo Form Class I ran into an interesting problem while using Rails with dojo: without the tweaks I made, a Form object cannot enclose multiple Dojo Layout objects like ContentPane. Thus, it was impossible to construct a form that wrapped a Top Toolbar (where Save and Cancel buttons live), and a main editing region below. Created a new Data Store Created a new Dojo Forest Store Model
Created a new Dojo Grid Model
Next Steps Sure, Rails provides core support for Optimistic Revision (if your model includes the lock_revision magic field), but it leaves you to your own devices to detect the "409 Conflict" HTTP error. You also receive an ugly "StaleObjectError" dump, and your Form-Submit data is pretty much lost unless you salvage them from the Rails Session. Rails Conflict Using the Dojo Data Store for Form Data Submission Thus, the plan is to use the custom Dojo Data Store to handle these conflicts. The data store I wrote already maintains the "revision 0" and "revision X" states to handle the dojo.data.api.Write interface, which includes a revert() operation. All that's needed is an HTTP Error trap that tests to see if we received a 409 Error, and issue a datastore fetchItemByIdentity() within the data store to pull in the "revision 1" state. Once all three are loaded, the data store can do a conflict-merge. If the fields changed in "Revision 1" don't conflict with "Revision X", then FANTASTIC - just submit the changes and be on our way. If a conflict is detected, though, the application should pop up a dialog-box -- "Revision X" is attempting to update a value that was already updated in "Revision 1". The dialog should instruct the user to do cancel the current changeset. Alternatively, a sophisticated application could reload the page with "revision 1" data, and highlight the conflicted fields for the user's review. Doing the conflict-resolution within the Data Store also has a side benefit: this little routine only needs to be written once, and will be available to ALL Rails on Dojo applications that are using this data store. Gap Analysis of Dojo Toolkit
I'm sure there are other gaps I'll find along the way, but these are the ones that really stick out. For the application I'm working on, these are pretty close to show-stoppers that I'll need to solve soon. Stuff For My Todo List I want the Rails/Dojo Form to render as normal, but the form should return false on submit to prevent the normal form-submit behavior. Instead, a notification to the Form Model should fired, along with the corresponding values from the Form. (using dojo.formToObject or some other formTo* variant, most likely..). Once the datastore item is updated in the Form Model, issue a save() -- or not. The actual save() action would depend on a cache setting within my data store implementation. The Rails/Dojo form could be a "Detail Form" for a selected Grid Line Item, and all saves are cached until a save() button is clicked in the Grid. (In this scenario, the "save button" on the Rails/Dojo form would really mean "save to data store cache"). Lots of design ideas to consider, and I'll get back to Rails/Dojo hacking in a week or two. Right now, I'm researching git for the next phase of this application I'm writing. I'm also looking for individuals or companies who may be interested in sponsoring this project to keep the momentum going. Heck, even an "Atta Boy!" from the blogosphere would be encouraging motivation.
|
|||
As I've previously mentioned, I'm having a blast doing "self-funded R&D". Playing with all these new technologies is a rewarding, refreshing change from the old Day Job, where I didn't have as much opportunity to play with these toys, figure out what toys I liked, and evangelize the hell out of 'em. On that note, I've recently been playing with Rails 2.0.2, using RadRails (Aptana Community Edition) on Fedora 8, of course. Just for fun, I've managed to graft a third-party Ajax Toolkit on top of it. While it's functional, this solution totally needs some work under the hood. Lots of hard-coded glue stubs just to get something barely operational. Blecch. Overall, though, I still kind of like how this little experiment is turning out. If you're looking for easy alternatives to do something similar, you might want to check out Jester.js as your middleware glue. It's essentially an ActiveResource proxy in the client's web browser, and is capable of making some of this glue work ridiculously easy. For this experiment, I decided against using Jester.js, as I wanted to get deep down and dirty, getting as hands-on with the integration as possible. Anyway. Here's a quick attempt to mock something up under my Frankenstein Solution. Yay, I have a TreeView. While the screenshot can't illustrate this, the TreeView actually does lazy-loading from the FrankensteinServer when you click on the tree nodes for expansion. OK, so maybe that's not the most impressive thing in the world. I still had a great deal of fun figuring all this stuff out. I'll post more impressive combinations as I prototype them. For now, though, I'm happy to have a starting point to work from.
|
|||






) One rather large design change that I'm considering is to abandon the use of all Form Submits, and use the Dojo Data Store to exchange everything. And before you dismiss me as being on crack, here's my reason for considering this route: Ruby on Rails has TERRIBLE SUPPORT for Forms-Based Concurrency Handling!




Recent comments
3 weeks 4 days ago
6 weeks 2 days ago
8 weeks 6 days ago
18 weeks 6 days ago
21 weeks 4 days ago
20 weeks 5 days ago
22 weeks 5 days ago
24 weeks 18 hours ago
24 weeks 1 day ago
27 weeks 1 day ago