Wednesday, May 21. 2008Zend Framework Dojo IntegrationI'm pleased to announce that Zend Framework will be partnering with Dojo Toolkit to deliver out-of-the-box Ajax and rich user interfaces for sites developed in Zend Framework. First off, for those ZF users who are using other Javascript toolkits: Zend Framework will continue to be basically JS toolkit agnostic. You will still be able to use whatever toolkit you want with ZF applications. ZF will simply be shipping Dojo so that users have a toolkit by default. Several points of integration have been defined, and my hope is that these can be used as a blueprint for community contributions relating to other javascript frameworks. In the meantime, developers choosing to use Dojo will have a rich set of components and integration points to work with. The integration points we have defined for our initial release are as follows:
So, some examples are in order. First off, // /json-rpc.php // Assumes you have a class 'Foo' with methods 'bar' and 'baz': $server = new Zend_Json_Server(); $server->setClass('Foo') ->setTarget('/json-rpc.php') ->setEnvelope('JSON-RPC-1.0') ->setDojoCompatible(true); // For GET requests, simply return the service map if ('GET' == $_SERVER['REQUEST_METHOD']) { $smd = $server->getServiceMap(); header('Content-Type: application/json'); echo $smd; exit; } $server->handle(); On your view script side, you might then do the following: <h2>Dojo JSON-RPC Demo</h2> <input name="foo" type="button" value="Demo" onClick="demoRpc()"/> <? $this->dojo()->setLocalPath('/js/dojo/dojo.js') ->addStyleSheetModule('dijit.themes.tundra') ->requireModule('dojo.rpc.JsonService'); $this->headScript()->captureStart(); ?> function demoRpc() { var myObject = new dojo.rpc.JsonService('/json-rpc.php'); console.log(myObject.bar()); } <? $this->headScript()->captureEnd() ?> And, finally, in your layout script, you might have the following: <?= $this->doctype() ?> <html> <head> <title>...</title> <?= $this->dojo() ?> <?= $this->headScript() ?> </head> <body class="tundra"> <?= $this->layout()->content ?> </body> </html> The example doesn't do much -- it simply logs the results of the JSON-RPC call to the console -- but it demonstrates a number of things:
There will be more to come in the future, and I will be blogging about developments as I get more proposals up and code into the repository. All in all, this is a very exciting collaboration, and should help provide ZF developers the ability to rapidly create web applications with rich, dynamic user interfaces. Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
The timing couldn't be much better for you to choose a JS lib. At work, we were just about to make a decision on what lib to go for in an upcoming project, and now it's pretty much obvious. Can't wait to try it out
Any estimates on when the new components will reach incubator/core? The JSON-RPC server is in a branch currently and will be moved to the incubator within the next week; it is fully unit tested as well as tested functionally with Dojo.
The dojo view helper is about 75% complete, and I will be posting it in a branch pending the completion of the proposal process (I can finally post a proposal now that we've broken silence The remainder will be done likely in the next 6 weeks (I have a lot of travelling in the next three weeks for work and conferences). Congrats matthew! Looking forward to this integration.
Thanks, Ivo -- it's been a long time coming, but the steps we've made the past couple months have been very big and promising. It's a very exciting partnership!
Hey Matthew, thanks for your work on ZF (and Zend_Form in particular), as well as on the great tutorial input here and on DevZone. I assumed the JS lib integration would end up with Dojo, being BSD-licensed, and so close in nature. One of the things that kept me from using Dojo widgets was and is the fact that they invalidate XHTML. (Hello World!). The issue is discussed every now and then on the Dojo forums, but I didn't find any "official" statements on the problem yet. So, I'm not sure if Andi's "Dojo not only implements published standards, but also drives them." is entirely correct. Being concerned about valid code, I am generally taking great care to use unobstrusive techniques in adding javascript functionalities, and I do hope that the ZF Dojo integration will follow, or at least allow for ways of programmatically building widgets rather than requiring to add invalid attributes to (X)HTML code.
Bernd I meant to add example code where it says "Hello World", which obviously was stripped out. I was referring to the dojoType or widgetId attributes etc.
If validation is a concern, Dojo allows you to do everything programmatically already, and I have done so myself in several projects.
Attributes like dojoType and widgetId are merely for convenience; it's easier to associate the behavior with the actual element than it is to write a bunch of javascript that decorates the page. The fact of the matter is that the methodology works in every major browser already, regardless of whether or not it validates; as such, it's a pragmatic approach. Some links for discussion points: http://alex.dojotoolkit.org/?p=622 http://alex.dojotoolkit.org/?p=642 Besides this, however, the standards I was primarily pointing at and that Andi references are things like Dojo's commitment to JSON-RPC, JSON-Schema, Bayeux, etc. They are working hard to help define Javascript standards to make it easier for developers to code UIs and server-side listeners. Imagine if you could write a single JSON-RPC server and swap out your client side with a new JS library without needing to change anything server side; this would be a huge gain. Thanks for the clarification, but one question stays:
How will the dojo helper work? Is there an option to tell them "do that programmatically" to keep the output valid? This is my biggest concern with Dojo. Guess I'll have a look at the code I'll be posting the proposal today or tomorrow, and will update this blog entry with a link to it.
The dojo() view helper simply sets up the various script/style includes, as well as any dojo.require statements and custom module paths. The part you're interested in will be with the form elements, for which there is no proposal yet, and for which I have not yet created any functionality. I think that programmatic creation would definitely be achievable, and I'll list it as a 'SHOULD' portion of the proposal when I create it. Hmm... I need to ship jQuery too, but I suppose two Js frameworks won't hurt
I'm just wondering: will those Dojo Form Elements also degrade nicely to plain HTML? If so, that would be excellent The dojo form elements will simply be automating some of the logic -- they will make use of the dojo() form helper to ensure the appropriate dojo.require statements are made, and will then inject the appropriate dojoType attribute. This means, simply, that yes, they _will_ degrade gracefully, just as Dojo does currently.
Great! (Sorry, I have no experience at all with Dojo so I didn't know...)
The very nature of jQuery, and its ability to be abstracted from html is one of its true beauties. I think its integration into the ZF will be much easier than Dojo from what I've seen.
I know this may be hard to believe, but I've found integrating _any_ JS library into ZF pretty trivial. Much of jQuery's simplicity has a direct correlation in dojo.query(), btw.
Additionally, the idea is that the Dojo integration will serve as a blueprint for community contributors to submit other JS library integration layers. Please stay tuned! Would be great something like this for jQuery, jQuey is a great toolkit, lots of plugins, strong community, will be awesome.
, Congrats I wish it were jQuery instead. Dojo, while being very powerful is one of the most complicated Javascript libraries around. Hopefully you'll consider other javascript framework helpers (or maybe I should submit a proposal?
We fully expected that regardless of the library we chose, we would not make everyone happy -- so, to that end, as I noted in the entry, we are a) making everything use-at-will, and b) expecting and encouraging community contributions of other javascript integration components. While we will not ship other libraries, we will ship the integration components. The intention is that the dojo integration will serve as a blueprint for such contributions.
And yes, proposals are always accepted. First, thanks for taking the time to comment on this.
I'm *very* biased (I work on Dojo itself), but Dojo isn't any more complicated than it is deep, which is to say, you only "pay" the complexity cost for the parts that you actually use. If you want to use Dojo in the exact same style as you use JQuery, you can do that (via dojo.query())....but Dojo picks up where JQuery leaves in the lurch by providing tools, modules, and support for building larger-scale interactions, optimizing for deployment, and handling internationalization, localization, and accessibility. Of course, you never hit those APIs unless you're doing something that requires them, and often not even then. As JQuery grows in scope, we expect to see them continuing to borrow many of the innovative features currently found in Dojo as the need to solve the same problems becomes as pressing for them as it was for Dojo when Dojo was pressed into service on large-scale sites like AOL Mail. That's not by way of saying that JQuery is bad, just to suggest that complexity is relative to the problem set you're trying to approach. Dojo gives you tools to attack a much larger range of problems...hence the depth and breadth of the toolkit. Regards I'm really disappointed, other frameworks that I'll won't name have better documentation, community and really better support. Dojo really lacks documentation. Without good docs, code examples, strong community and a good API browser (like that of ZF) I'll go elsewhere. I hope ZF will stay JS independent.
Dojo's documentation has improved vastly in the past several months, and projects like DojoCampus (http://dojocampus.org/) are providing concrete examples for developers to utilize to achieve complex effects (and trivial ones, as well). Additionally, Dojo now has API docs online (http://api.dojotoolkit.org/).
ZF _will_ remain JS library independent, in that we will not be integrating Dojo in such a way that Dojo is the only option; the idea is that the Dojo integration will serve as a blueprint for other JS library integration components. Dojo _will_ be the only JS library shipped with ZF for the forseeable future, however. Hey I tried the URL you provided with your branch http://framework.zend.com/svn/framework/branch/user/matthew/zed_json_server and I got a 404 error page...
Is this the right URL? I have to try your new library The JSON-RPC server is now in the standard incubator:
http://framework.zend.com/svn/framework/standard/incubator as the component 'Zend_Json_Server'; it will be promoted into the standard library in the coming weeks as it is fully documented and tested now. I 've some feedback fro your Zend_Dojo_View helper...
When i was trying to use your helper the following error came up: Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 22 in /.../Zend/Dojo/View/Helper/Dojo/Container.php on line 504 I did some research on regular expressions and found out that the line: $localPath = preg_replace('|dojo[/\\]dojo.js[^/\\]*$|i', '', $localPath); must be replaced with: $localPath = preg_replace('|dojo[/\\\\]dojo.js[^/\\\\]*$|i', '', $localPath); Thanks for the report; I've fixed this in svn now.
In the future, please direct such comments to the ZF mailing lists. Is the Menu style in DoJo, I checked in there site, I could not find any Script.
Add Comment
|
Calendar
QuicksearchLinks
CategoriesSyndicate This BlogShow tagged entries |
|||||||||||||||||||||||||||||||||||||||||||||||||




