Dojo Tool Kit

1.What is and Why Dojo Toolkit ?

  • Dojo toolkit is open source DHTML toolkit written in JavaScript. In other words, it is a set of JavaScript libraries.
  • Dojo toolkit aims to solve some long-standing historical problems with DHTML such as browser incompatibility.
  • Dojo toolkit also allows you easily add dynamic capabilities into the web pages by the usage of pre-built widgets and animations.
  • Because it is client-side technology, it can work with any server side technology.

2.What is Dojo Toolkit ?

  • Open Source DHTML toolkit written in JavaScript.
  • It is a set of JavaScript libraries.
  • Aims to solve some long-standing historical problems with DHTML – Browser incompatibility.
  • Allows you to easily build dynamic capabilities into web pages ie. Widgets, Animations.
  • You can use Dojo toolkit to make your web applications to be more usable, responsive, and functional.
  • Using Dojo toolkit is one of the most effective means of building AJAX based Web applications.
  • Dojo provides lots of plumbing facilities, for example, it hides low-level XMLHttpRequest processing.
  • It also handles browser incompatibilities.

3. Why Dojo Toolkit ?

  • You can use Dojo to make your web applications more useable, responsive, and functional Supports AJAX.
  • Dojo provides lots of plumbing facilities i.e.Hides XMLHttpRequest processing, Handles browser incompatibilities.
  • Dojo provides powerful AJAX-based IO abstraction. What this means is that it handles asynchronous communication
    through the usage of XMLHttpRequest. Again this is called remoting.
  • It provides hooks for backward, forward, bookmarking support.
  • Its event system is pretty powerful, for example, it lets you to invoke your event handler before or after an event occurs.
    This is called “aspect-oriented” event system.
  • It does provide markup based UI constructions through widgets. You can also build and reuse widgets that you built or built by someone else.
  • It does support animation. And again, Dojo toolkit comes with lots of useful JavaScript libraries.

4. Features of Dojo Toolkit ?

  • Powerful AJAX-based I/O abstraction (remoting).
  • Graceful degradation.
  • Backward, forward, bookmarking support.
  • Aspect-oriented event system.
  • Markup-based UI construction through widgets.
  • Widget prototyping.
  • Animation

5.List out the Dojo Toolkit Libraries ?

dojo.io: AJAX-based communication with the server
dojo.event: unified event system for DOM and programmatic events
dojo.lang: utility routines to make JavaScript easier to use.
dojo.string: String manipulation routines
dojo.dom: DOM manipulation routines
dojo.style: CSS Style manipulation routines
dojo.html: HTML specific operations
dojo.reflect: Reflection API
dojo.date: Date manipulation
dojo.logging.Logger: Logging library
dojo.profile: JS Profiler
dojo.regexp: Regular Expression generators
dojo.dad: Drag and Drop
dojo.collections: Collection data structures
dojo.crypto: Cryptographic API
dojo.reflection: Reflection routines
dojo.math: Mathematic routines
dojo.storage: Storage routines
dojo.uri: URL handling routines
dojo.widget: Widget framework

6.Explain Event System in Dojo ?

Dojo’s event system offers a refreshing alternative to the normal JavaScript events. With Dojo, you connect functions to one another, creating a link that calls one function when another fires.

dojoAttachEvent

dojoAttachEvent allows you to specify DOM event handlers in a very concise manner:

dojo.webui.widgets.MyWidget = function() {

this.templateString = ‘<div dojoAttachPoint=”divNode”
dojoAttachEvent=”onClick; onMouseOver: onNode;”></div>’;
}

In other words, for a widget that contains the above templateString, there is a div node, that will listen for onclick and onmouseover DOM events. The onclick event will be routed to a handler called onClick for that widget, while the onmouseover event will be routed to handler onNode

dojo.webui.widgets.MyWidget = function() {

this.onClick = function(evt) {
// do something when clicking on the div for this widget
}

this.onNode = function(evt) {
// do something else when mousing over the div for
// this widget
}

}

Note that onNode and onClick are just arbitrary names of methods in the widget. The limitation of dojoAttachEvent is that it only currently works for binding from DOM events.

dojo.event.connect

dojo.event.connect is a mechanism for connecting a dom event or method call to another event handler or method call:

dojo.webui.widgets.MyWidget = function() {

dojo.event.connect(this.divNode, “onclick”, this, “onClick”);
dojo.event.connect(this, “onClick”, this, “onNode”);
dojo.event.connect(widgetBar, “onBar”, this, “onNode”);

}

The first connect method above does the same thing as the example above defined with dojoAttachEvent.
The second one is more interesting, as it connects the onClick handler method to another method called onNode.
The third example shows how you might connect any two method from any two objects.

dojo.event.topic

Say you have a case where you have a number of widgets in a document, and you want them all to be able to listen for the same event, and also push events to the other widgets that are listening. With the normal dojo.event.connect, you would need to create a connection between each set of widgets manually. Instead, you just do the following:

// to send/publish an event to the topic
dojo.event.topic.publish(“recordFound”, newRecord);
// to listen/subscribe to all events published to a topic
dojo.event.topic.subscribe(“recordFound”, this, “onNode”);

disconnect and unsubscribe

To remove an event connection or a topic subscription, dojo.event.disconnect and dojo.event.topic.unsubscribe take exactly the same parameters as their counterparts.

Advertisements