Speak Dojo
Dojo is an Open Source JavaScript UI toolkit. It makes writing JavaScript easier, building great interfaces faster, and deploying dynamic UIs at scale much easier. The foundation of Dojo is “Dojo Base”, a single tiny library which contains Ajax, event handling, effects, blazing fast CSS queries, language utilities, and a lot more. On top of this Base, the rest of Dojo Core adds high-quality facilities for Drag and Drop, extended forms of Ajax and I/O, JSON-RPC, internationalization, and back-button handling.
You can use the div tag to define widget locations and Dojo will place the widget there either during page load or in response to events.
dojo book 0.4 –API — reference documentation — Dojo jot wiki — dojo toolkit home
JavaPassion PDF has 86 pages of info.
What is JSON?
(Using Dojo and JSON to Build Ajax Applications article ) – JSON is a Java library that helps convert Java objects into a string representation. This string, when
eval()ed in JavaScript, produces an array that contains all of the information that the Java object contained.JSONObjectclass ,JSONArrayclass “- Dojo provides an abstraction layer for invoking JSON-RPC requests”IBM Paper: “JSON is built on two structures:
- A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
- An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence
JSON-RPC is a lightweight remote procedure call protocol in which JSON serializes requests and responses
The request is a single object with three properties:
method– A string containing the name of the method to be invoked.params– An array of objects to pass as arguments to the method.id– The request ID. This can be of any type. It is used to match the response with the request that it is replying to.When the method invocation completes, the service must reply with a response. The response is a single object with three properties:
result– The object that was returned by the invoked method. This must benull, in case there was an error invoking the method.error– Anerrorobject if there was an error invoking the method. It must benull, if there was no error.id– This must be the same ID as the request it is responding to.A notification is a special request that does not have a response. It has the same properties as the request object with one exception:
id– Must benull“
Using Dojo and JSON to Build Ajax Applications article: Dojo libraries are organized in packages just like Java code. For this example, we will need to import two packages.
The
dojo.iopackage contains classes that allow us to make HTTP requests using protocols such as XMLHTTPTransport.The
dojo.eventpackage is designed to provide a unified event system for DOM and programmatic events.The
dojo.event.connect()method allows you to associate a handler for theonclickevent formyButton:function onLoad() { var buttonObj = document.getElementById("myButton"); dojo.event.connect(buttonObj, "onclick", this, "onclick_myButton"); }function onclick_myButton() { var bindArgs = { url: "welcome.jsp", error: function(type, data, evt){ alert("An error occurred."); }, load: function(type, data, evt){ alert(data); }, mimetype: "text/plain", formNode: document.getElementById("myForm") }; dojo.io.bind(bindArgs); }The magical
dojo.io.bind()function is where the power lies. It takes as argumentbindArgs, an array of name/value pairs. In this example, we specify five pairs:
url: The URL to make the request to.mimetype: The response type expected.load: Code to execute upon success.error: Code to execute upon error.formNode: The ID of the form whose fields to submit as parameters to the URL.Once the call to
dojo.io.bind(bindArgs)is made,depending on whether the request encountered any errors, either theloadorerrorcode is executed. Bothloadanderrortake three arguments:: The type of function; it will always be set to
typeloadforload()anderrorforerror().: The response received. If
datamimetypeis specified astext/plain, data contains the raw response. If, however,text/jsonis used, data contains the value ofeval('(' + responseReceived + ')'), whereresponseReceivedis what the call returned.
evt: The event object.
- Dojo with a struts action example
- http://dojotoolkit.org/search/node/tree
- http://willcode4beer.com/ware.jsp?set=dojoTreeWidget
- http://www.sauter-online.de/dojo/demos/widget/Tree/tree.html
- http://www.thearcmind.com/confluence/display/RandomThoughts/DOJO+First+Glance
- http://dojo.jot.com/WikiHome/Tree
- http://home.exetel.com.au/cweatures/combosample/combotest.html
- http://www.stack.be/~roel/blog/archives/the-dojo-tree-control-for-beginners-part-1/
- http://www.stack.be/~roel/blog/archives/the-dojo-tree-control-for-beginners-part-2/
- http://www.it-eye.nl/weblog/2007/05/02/use-ajax-treecompontent-in-jsp-with-dojo/
No comments yet.


