Getting Started - Setting dojoroot
17 Jul 2008, 05:14
Bob Furber (1 post)
I am stuck at chapter 2 of Mastering Dojo because I am missing something that must be so obvious to everyone but me: How to set dojoroot.
The Dojo Getting Started page suggests accessing the dojo resources directly from AOL’s Content Distribution Network (CDN). This means that one must somehow assign the CDN’s URL to dojoroot, or do massive editing of all paths containing dojoroot to replace each occurrence by CDN’s URL.
Can this be done? How? Where?
In the meantime, I have placed the dojo files in C:\IntecDev\tomcat\webapps\dojo-1.1.1 on my PC. For instance, the path to the digit folder is C:\IntecDev\tomcat\webapps\dojo-1.1.1\dijit
Demo applications are in the C:\IntecDev\tomcat\webapps\dojo-1.1.1\RGdojo\ folder. For instance the path to hello_dojo_world.html is C:\IntecDev\tomcat\webapps\dojo-1.1.1\RGdojo\advanced_forms_made_easy\hello_dojo_world.html.
In order to run the demos directly from the files, either I have to massively edit the paths to the dojo resources (did not work) or, I have to somehow assign a value to dojoroot of (\..\..\..\dojo-1.1.1). But, how do I do this? Where?
Out of desperation, I attempted a different file structure, as suggested in http://cs.calstatela.edu/wiki/index.php/Courses…. I placed a dojoroot directory in the advanced_forms_made_easy/ directory and placed the dojo files in it, such that the path to the digit folder was advanced_forms_made_easy/dojoroot/digit/.
Alas, the demos in advanced_forms_made_easy would not load correctly because of a (dojo is not defined) error in dojo.require(dojo.parser) ..quotes omitted.
Attempts to serve the demos with Tomcat resulted in:
Moreover, there is still the issue of setting dojoroot.
I am totally lost. Can someone point me in the right direction?
22 Jul 2008, 04:25
Rawld Gill (16 posts)
I’m not sure exactly what you’re referring to when you say “The Dojo Getting Started page” (though I’m pretty sure you’re not referring to anything in the book). Give me an address and maybe I can give you some more help with whatever it says.
In any event, we wrote all the examples assuming that dojo and the example code (html, css, js) exist on the same server (no cross-domain issues). dojoroot points to the directory that holds the dojo, dijit, dojox, and util directories contained in a release package distributed at http://download.dojotoolkit.org/.
Note that this implies: you cannot run the demos without a web server because you need to alias dojoroot to its actual location (in your case “C:\IntecDev\tomcat\webapps\dojo-1.1.1”). Since XHR isn’t really designed to work with the file:/// protocol and demonstrating/experimenting with several concepts is fairly artificial with file:///, we chose to write the book assuming a web server is being used. I’d have to debug your “dojo not defined” error, but I suspect it is a file:/// protocol issue.
I super-simple way to get this up is to use a Ruby WEBrick server. Here is the code for the configuration you outlined above:
Save this in a file, say dojoserver.rb, and then execute “ruby dojoserver.rb” from the command prompt. Notice that this is set up to hit port 8002. So the url would be (e.g.) http://localhost:8002/advanced_forms_made_easy/hello_dojo_world.html
WEBrick is included in Ruby. It looks like you’re on Windows—you can get ruby quite easily at http://rubyforge.org/frs/download.php/29263/rub….
Finally, note that the RIA example at the end of the book uses a different server for each step. The WEBrick servers are included in the code. See my post at http://forums.pragprog.com/forums/58/topics/453
Feel free to ping me at “email@example.com” for more help.
29 Oct 2012, 17:53
Matthew Grecar (3 posts)
Worked like a charm for me, thanks for this great post, got me right into Dojo without screwing around with infrastructure!
|You must be logged in to comment|