Rich internet application development using the dojo toolkit

Rich internet application development using the dojo toolkit
Rich Internet Application
         development using
             the Dojo Toolkit


FrOSCon, Sankt Augustin, 20. August 2011
                     Dr. Alexander Kläser
             klaeser at univention dot de
Goal of this presentation

                              Brief overview of existing JavaScript frameworks
                              General overview of Dojo (structure, features, resources)
                                   Know what you can do with it and whether it could help you
                              Some details w.r.t. Rich Internat Application (RIA)
                              development using Dojo




RIA development using the Dojo Toolkit                                                          3
Presentation outline

Overview over JavaScript
Frameworks
Overview over the Dojo Toolkit
Dojo core features
Dojo and Widgets
Presentation outline

Overview over JavaScript
Frameworks
Overview over the Dojo Toolkit
Dojo core features
Dojo and Widgets
Our situtation @Univention
                              Redesign of our administrative web frontend… what it can do:
                                   Domain wide configuration: users, groups, computers, ACLs, DNS,
                                   DHCP, mail, shared folders, printers, Nagios, policies, ...
                                   Computer wide configuration: system statistics, software
                                   management, process overview, ...
                                   Virtual machine management
                                   Thin client services
                                   Management system for school environments (class rooms, …)
                                   ...
                              Solution: rewrite the client side part as RIA (w/AJAX technologies)
                                   Communication with existing server part (written in Python)
                                   A JavaScript library simplifies cross-browser compatibility



RIA development using the Dojo Toolkit                                                               6
JavaScript libraries overview
                              There are many (OpenSource) JavaScript libraries:
                                   Prototype, JQuery, Yahoo UI, Dojo, Mootools, ExtJS, ...




                              Note: "JavaScript Prototype" is not necessarily the library
                              Is the winner JQuery?

RIA development using the Dojo Toolkit                                                       7
Our conclusions
                             JQuery is a very popular library
                                 Great for manipulating the DOM
                                 But, no ready-to-use infrastructure for RIA (see below)
                             ExtJS and Dojo seem to be the only libraries that offer a rich feature set:
                                 Many widgets, consistent API, module management, i18n, l10n, layout management, DOM
                                 manipulation, data abstraction, OOP, theming, data grids, build system etc.
                             ExtJS
                                 Many features and widgets, a very good documentation with tutorials
                                 Development is closed (product of the company Sencha)
                                 Dual licensing model (commercial + LGPL)
                             Dojo
                                 Open development
                                 License: Academic Free License v2.1 and modified BSD license
                                 Non-profit Dojo Foundation holds intellectual property rights
                             ... so the winner is Dojo... (at least in our case)
                             See also: http://dojotoolkit.org/reference-guide/quickstart/introduction/whydojo.html


RIA development using the Dojo Toolkit                                                                                 8
Presentation outline

Overview over JavaScript
Frameworks
Overview over the Dojo Toolkit
Dojo core features
Dojo and Widgets
Statistics about Dojo
                                             (lines of code)




RIA development using the Dojo Toolkit                           10
Statistics about Dojo
                                          (commits per month)




RIA development using the Dojo Toolkit                           11
Statistics about Dojo
                                          (commiters per month)




RIA development using the Dojo Toolkit                            12
Dojo overview
                              Dojo consists of 3 main parts...
                              dojo: the core
                                   Browser normalization, module loading, DOM manipulation, events,
                                   string functions, data access, drag 'n' drop, XHR calls, JSON
                                   encoding/decoding, effects/animations, OOP etc.
                              dijit: interface widgets, advanced UI controls, template driven
                                   Form elements (calendar, dynamic combo boxes, slider etc.),
                                   dialogs, tree, layout, menus, tooltips, WYSIWYG editor etc.
                              dojox: various extra projects, partly experimental
                                   More widgets, charts, data grid, file uploads, dynamic CSS rules,
                                   collections, syntax highlighting, sprintf, more editor plugins, more
                                   animation effects, JSON schema validation, JSON query syntax etc




RIA development using the Dojo Toolkit                                                                    13
Dojo philosophy
                              Non-intrusive
                                   Native objects (e.g., Array, String) are not extended with additional
                                   functionality
                                   Instead extensions are provided in a clean separate namespace
                                   When possible, these extensions (functions) refer to existing, native
                                   implementations of the browser
                              Ease of use and performance
                              Code that is as simple as possible
                              High-quality "full-stack" library
                              Dojo is modular, modules are loaded when need




RIA development using the Dojo Toolkit                                                                     14
How to use Dojo
                          <!DOCTYPE html>
                          <html>
                          <head>
                            <meta charset="utf-8">
                            <title>Tutorial: Hello Dojo!</title>
                            <!-- load Dojo and style sheets for widgets -->
                            <script src="...dojo/dojo.js"></script>
                            <link rel="stylesheet" type="text/css"
                          href="...dojo/resources/dojo.css" />
                            <link rel="stylesheet" type="text/css"
                          href="...dijit/themes/claro/claro.css" />
                            <!-- ... eventually other widget specific CSS files ... -->
                          </head>
                          <body class="claro">
                              <h1 id="greeting">Hello</h1>
                          </body>
                          </html>




RIA development using the Dojo Toolkit                                                    15
Presentation outline

Overview over JavaScript
Frameworks
Overview over the Dojo Toolkit
Dojo core features
Dojo and Widgets
Dojo Base
                              Base: no additional module needs to be loaded
                              Execute JS functions when then DOM is ready: dojo.addOnLoad() /
                              dojo.ready()
                              Packaging mechanism: dojo.require(), dojo.provide()
                                   Separation of code, usage of namespaces improves reusability :)
                                   Namespaces: dojo.foo.bar → dojo/foo/bar.js
                                   Browser can load modules on demand → one module, one file
                                   No need to track dependencies (a module can load another module)
                                   A module is just a file, otherwise there is no restriction (may declare
                                   any kind of class)
                                   Modules in dojo/dijit are already compatible with the AMD API
                                   (Asynchronous Module Definition), see:
                                   http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition


RIA development using the Dojo Toolkit                                                                       17
Dojo Base
                                         (packaging mechanism)

                          // some code...
                          dojo.require("my.Module"); // → my/Module.js
                          dojo.addOnLoad(function(){
                              var m = new my.Module();
                              // ...
                          });

                          // in the package my/Module.js
                          dojo.provide("my.Module");
                          dojo.require("my._ClassBase"); // → my/_ClassBase.js

                          dojo.declare("my.Module", my._ClassBase, {
                              // ... the code ...
                          });



RIA development using the Dojo Toolkit                                           18
Dojo Base
                                           (object oriented programming)
                              Dojo provides tools to make object oriented programming in JS
                              easier (encapsulating the prototype)
                                   Declaring classes w/inheritance: dojo.declare()
                                   Call to parent method: this.inherited(arguments)
                                   Extend existing classes: dojo.extend()
                                   Mixins: dojo.mixin(), dojo.delegate()
                              Use of mixins
                                   A mixin provides certain functionality (methods, variables) via
                                   inheritance
                                   Mixin cannot be instantiated alone
                              For multiple inheritance
                                   Dojo uses C3 linearization (as Python, Perl) to resolve the order in
                                   which methods are inherited


RIA development using the Dojo Toolkit                                                                    19
Dojo Base
                                         (object oriented programming 2)
                          dojo.declare("some.Child", [ some.Parent, some.OtherParent ],
                          {
                              myVal: "default value",

                                constructor: function(args){
                                    // parent constructor is automatically called
                                    dojo.mixin(this, args);
                                }

                                myMethod: function() {
                                    // call overloaded parent method via this.inherited()
                                    this.inherited(arguments);
                                    // mycode...
                                }
                          });

                          var a = new some.Child();
                          var b = new some.Child({ myVal:"x" });
                          // a.myVal == "default value"
                          // b.myVal == "x"


RIA development using the Dojo Toolkit                                                      20
Dojo Base
                                           (signals/events, language tools)
                              Events, signal handling
                                   Normalization of events
                                   Signal mechanism for events/function calls: dojo.[dis]connect()
                                   Publish/subscribe mechanism: dojo.publish(), dojo.subscribe()
                              Language tools
                                   Scoping & function parameters: dojo.hitch(), dojo.partial()
                                   Type checking: dojo.is[String,Array,Function,Object,Alien]()




RIA development using the Dojo Toolkit                                                               21
Dojo Base
                                         (signals/events, language tools 2)
                          obj = {
                              foo: function() { console.log('obj.foo()'); },
                              bar: function() { console.log('obj.bar()'); },
                              val: 42
                          };
                          dojo.connect(obj, 'foo', obj, 'bar');
                          dojo.connect(obj, 'foo', dojo.hitch(obj, function() {
                              // we are in the scope of 'obj'
                              console.log('signal for obj.foo()');
                              console.log('this.val=' + this.val); // this.val == 42
                          }));
                          obj.foo();

                          /* output:
                          obj.foo()
                          obj.bar()
                          signal for obj.foo()
                          this.val=42 */
                          /* full code: http://jsfiddle.net/rTUfr/1/ */

                          // ... it is also possible to connect to DOM-events
                          dojo.connect(domNode, "onclick", dojo.hitch(this, "handleClick"));


RIA development using the Dojo Toolkit                                                         22
Dojo Base
                                         (utilities for arrays, strings, and others)
                              Array utility functions:
                                   Iteration: dojo.forEach(), dojo.map()
                                   Filtering: dojo.filter()
                                   Condition check: dojo.every(), dojo.some()
                                   Index of a given element: dojo.indexOf()
                              String processing:
                                   dojo.trim()
                                   A template mechanism: dojo.replace()
                              JSON conversion: dojo.toJson(), dojo.fromJson()
                              Browser Sniffing: dojo.isIE < 7, isFF, isWebKit ...




RIA development using the Dojo Toolkit                                                 23
Dojo Base
                                               (Ajax calls, dojo.Deferred)
                              Ajax wrapper functions: dojo.xhr[Get,Post,Delete,Put]()
                              Handling of asynchronous events: dojo.Deferred
                                   Asynchronous operation abstraction
                                   Return a dojo.Deferred if the function is asynchronous
                                   Multiple dojo.Deferred can be nested and chained




RIA development using the Dojo Toolkit                                                      24
Dojo Base
                                          (Ajax calls, dojo.Deferred 2)
                          // xhrPost() returns an object of type dojo.Deferred
                          var deferred = dojo.xhrPost({
                              url: '/echo/json/',
                              handleAs: 'json',
                              content: { /* ... a dict of name/string pairs ... */ }
                          });

                          // register callback... then() returns a new deferred
                          deferred = deferred.then(function(data) {
                              var str = '';
                              dojo.forEach(data.messages, function(i) {
                                  str += '<div>' + i + '</div>';
                              });
                              dojo.body().innerHTML = str;
                              return data.value; // return value is fed to next deferred
                          });

                          // deferreds can be chained
                          deferred.then(function(value) {
                              dojo.body().innerHTML += '<div>Value: ' + value + '</div>';
                          });

                          /* full code: http://jsfiddle.net/hMREq/5/ */


RIA development using the Dojo Toolkit                                                      25
Dojo Base
                                         (DOM/CSS manipulation, animation)
                              Querying DOM nodes
                                   With standard CSS3 selectors: dojo.query()
                                   By their ID: dojo.byId()
                                   Chaining of DOM manipulation: dojo.NodeList
                              Placement in the DOM: dojo.place()
                              Manipulation of DOM attributes: dojo.attr()
                              Manipulation of CSS style: dojo.style()
                              Manipulation of CSS classes: dojo.[add,remove,has]Class()
                              Manipulation/querying of DOM node size/position: dojo.coords(),
                              dojo.position(), dojo.[margin,content]Box()
                              Animation: dojo.fadeIn/Out(), dojo.animateProperty()



RIA development using the Dojo Toolkit                                                          26
Dojo Base
                                         (DOM/CSS manipulation, animation 2)
                          // dojo.query uses standard CSS3 selectors
                          // it returns a dojo.NodeList, a subclass of Array
                          dojo.query("ul > li").forEach(function(n){ ... });
                          dojo.query("#mycontainer").addClass("mylist");
                          dojo.query("a").onclick(function(){ ... });
                          dojo.query(".styleA.styleB").map(function(n){ ... });

                          // calls can be chained
                          dojo.query(".container")
                              .addClass('newClass')
                              .fadeIn().play();

                          // other kinds of manipulation
                          dojo.style(domNode, "height", "50px");
                          dojo.place("<p>Hi</p>", dojo.body());
                          dojo.addClass(domNode, "myCssClass");
                          var width = dojo.marginBox(domNode).w;
                          dojo.marginBox(domNode, {w: 300, h: 400});
                          dojo.fadeIn({ node: node }).play();


RIA development using the Dojo Toolkit                                            27
Dojo core
                              Core: everything else below dojo.* that needs to be loaded via
                              dojo.require()
                              Dojo's Dom/Widget parsing package: dojo.parser (→ see dijit)
                              Effects library on top of base animations: dojo.fx.[sizeTo(),
                              slideBy(), crossFade(), wipeTo(), smoothScroll()]
                              Utility classes for internationalization: dojo.i18n
                              More string functions: dojo.string
                              Caching of inline text: dojo.cache()
                              HTTP cookie manipulation: dojo.cookie()
                              Data access/manipulation layer: dojo.store (obsolete API is
                              dojo.data)
                              …


RIA development using the Dojo Toolkit                                                         28
Build system
                              Works transparently with Package System
                              Collects all referenced JS module files of an Dojo application and
                              builds a single minified JS file
                                   Minification: Comments, whitespace, newlines are removed, local
                                   variables names replaced by short ones
                              …




RIA development using the Dojo Toolkit                                                               29
Presentation outline

Overview over JavaScript
Frameworks
Overview over the Dojo Toolkit
Dojo core features
Dojo and Widgets
Dijit
                              dijit = Dojo widgets
                              A widget encapsulates the DOM representation and offers a
                              convenient object-oriented interface
                                   Events, attribute settings, GUI logic, …
                              Widgets are created in a programmatic or a declarative manner
                              Types of widgets:
                                   Layout widgets (border, tabs, accordion, ...)
                                   Form widgets w/validation (drop down, date pickers, popup, ...)
                                   Dialogs, Menus, …
                              Support for i18n
                              Widgets are themeable



RIA development using the Dojo Toolkit                                                               31
Screenshot




                          See: http://download.dojotoolkit.org/release-1.6.1/dojo-release-1.6.1/dijit/themes/themeTester.html




RIA development using the Dojo Toolkit                                                                                          32
Widgets from markup (declarative)
                          <div dojoType="dijit.layout.TabContainer" style="width:
                          100%; height: 100%;">
                              <div dojoType="dijit.layout.ContentPane" title="Tab 1"
                          selected="true">
                                  Content tab 1
                              </div>
                              <div dojoType="dijit.layout.ContentPane" title="Tab 2">
                                  Content tab 2
                              </div>
                          </div>

                          /* specify 'djConfig="parseOnLoad:true' in script tag... */

                          /* ... after loading, Dojo will parse the DOM tree */

                          /* full code: http://jsfiddle.net/H4DXH/ */




RIA development using the Dojo Toolkit                                                  33
Widgets from code (programmatic)
                          dojo.require("dijit.layout.TabContainer");
                          dojo.require("dijit.layout.ContentPane");
                          dojo.addOnLoad(function() {
                              // Create outer tab container
                              var container = new dijit.layout.TabContainer({
                                  style: 'height: 100%; width: 100%;'
                              });
                              container.placeAt(dojo.body());

                                // Construct tab content panes
                                dojo.forEach([1, 2], function(i) {
                                    container.addChild(new dijit.layout.ContentPane({
                                         title: 'Tab ' + i,
                                         // 'content' can be HTML, DOM-node, or Dojo-widget
                                         content: 'Content tab ' + i
                                    }));
                                });
                                container.startup();
                          });

                          /* Extensive use in RIA: dynamic creation/manipulation of widgets   */

                          /* full code: http://jsfiddle.net/ghZxW/10/ */


RIA development using the Dojo Toolkit                                                             34
Special widget classes
                              Base class: dijit._Widget
                                   Base class for all widgets
                                   Provides many basic features for widgets (attributes, watch,
                                   connect, DOM handling, …)
                              Template: dijit._Templated
                                   Mixin dijit._Templated to support building dijit UI using templates
                                   Template: custom HTML code with variable/event hooks
                                   Use dojoAttachPoint and dojoAttachEvent in HTML-tags to reference
                                   DOM nodes and add event listeners
                              Container
                                   Mixin dijit._Container to support managing children dijits
                                   Container's startup() calls children's startup()
                                   Removing a child dijit from the container doesn't destroy it

RIA development using the Dojo Toolkit                                                                   35
Widget attributes
                              dijit._Widget.set() is the standard API to set and get attributes
                                   If necessary, custom setter/getter functions can be provided
                                   Setter functions : _setXXXAttr()
                                   Getter functions : _getXXXAttr()
                                   For the attribute email : _setEmailAttr() and _getEmailAttr()
                              dijit._Widget.watch() notifies observers upon attribute changes
                              Attributes are mapped to DOM nodes via attributeMap
                                   Attribute modification updates the DOM node automatically




RIA development using the Dojo Toolkit                                                             36
Dijit life cycle – creation
                              preamble() - originates from dojo.declare
                                 Advanced feature, return value is passed over to constructor
                              constructor() - originates from dojo.declare
                                 Initialize and add addtitional properties
                              postMixInProperties() - originates from dijit._Widget
                                 All member methods/variables have been mixed in from all ancestors
                              buildRendering() - originates from dijit._Widget
                                 DOM nodes are set up
                              postCreate() - originates from dijit._Widget
                                 Executed when widget is created and visibly placed in the DOM
                                 Children cannot be safely accessed here
                              startup() - originates from dijit._Widget
                                 Fires when widget and all children have been created
                                 For programmatic approach: call startup() manually after adding all children

RIA development using the Dojo Toolkit                                                                          37
Dijit life cycle – destruction
                              destroy() - originates from dijit._Widget
                                  Destroys widget itself
                              destroyRecursive() - originates from dijit._Widget
                                  Destroys children and widget itself
                              uninitialize() - originates from dijit._Widget
                                  Destructor method for custom clean-up
                              See also: http://dojotoolkit.org/reference-guide/dijit/_Widget.html

                                                            destroyRecursive()

                          recursive call
                                             destroyDescendants()              destroy()


                                                              uninitialize()           destroyRendering()
                               custom code goes here

RIA development using the Dojo Toolkit                                                                      38
Conclusion

                              There are many JavaScript libraries out there
                              Yet only a few provide a good feature set for Rich Internet
                              Application (RIA) development
                              The Dojo Toolkit
                                   OpenSource license & open development
                                   Many features & good quality code
                                   Many widgets that are themeable
                                   Great for RIA development & pure DOM manipulation




RIA development using the Dojo Toolkit                                                      39
The end…

  Thank you very much for your
  attention!
  Much more could be said…
  Do you have questions?




Resources
  http://dojotoolkit.org/
  http://dojotoolkit.org/api/
  http://dojotoolkit.org/reference-guide/
  http://dojotoolkit.org/documentation/
  http://www.sitepen.com/blog/
1 of 40

Recommended

Building Real-World Dojo Web Applications by
Building Real-World Dojo Web ApplicationsBuilding Real-World Dojo Web Applications
Building Real-World Dojo Web ApplicationsAndrew Ferrier
5K views43 slides
Dojo - from web page to web apps by
Dojo - from web page to web appsDojo - from web page to web apps
Dojo - from web page to web appsyoavrubin
1.4K views35 slides
Dojo javascript toolkit by
Dojo javascript toolkit Dojo javascript toolkit
Dojo javascript toolkit Predhin Sapru
5.8K views118 slides
The Dojo Toolkit An Introduction by
The Dojo Toolkit   An IntroductionThe Dojo Toolkit   An Introduction
The Dojo Toolkit An IntroductionJeff Fox
5.5K views44 slides
Dojo & HTML5 by
Dojo & HTML5Dojo & HTML5
Dojo & HTML5Mike Wilcox
5.6K views265 slides
How dojo works by
How dojo worksHow dojo works
How dojo worksAmit Tyagi
8.6K views34 slides

More Related Content

What's hot

Moving to Dojo 1.7 and the path to 2.0 by
Moving to Dojo 1.7 and the path to 2.0Moving to Dojo 1.7 and the path to 2.0
Moving to Dojo 1.7 and the path to 2.0James Thomas
5K views98 slides
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014 by
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014Endava
4.3K views14 slides
Dojo, from scratch to result by
Dojo, from scratch to resultDojo, from scratch to result
Dojo, from scratch to resultNikolai Onken
4.3K views89 slides
JavaScript Libraries (Ajax Exp 2006) by
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)jeresig
3.1K views62 slides
Starting with jQuery by
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
1.7K views39 slides
Incremental DOM and Recent Trend of Frontend Development by
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentAkihiro Ikezoe
4.8K views44 slides

What's hot(20)

Moving to Dojo 1.7 and the path to 2.0 by James Thomas
Moving to Dojo 1.7 and the path to 2.0Moving to Dojo 1.7 and the path to 2.0
Moving to Dojo 1.7 and the path to 2.0
James Thomas5K views
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014 by Endava
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Endava4.3K views
Dojo, from scratch to result by Nikolai Onken
Dojo, from scratch to resultDojo, from scratch to result
Dojo, from scratch to result
Nikolai Onken4.3K views
JavaScript Libraries (Ajax Exp 2006) by jeresig
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
jeresig3.1K views
Starting with jQuery by Anil Kumar
Starting with jQueryStarting with jQuery
Starting with jQuery
Anil Kumar1.7K views
Incremental DOM and Recent Trend of Frontend Development by Akihiro Ikezoe
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend Development
Akihiro Ikezoe4.8K views
HTML5: An Introduction To Next Generation Web Development by Tilak Joshi
HTML5: An Introduction To Next Generation Web DevelopmentHTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web Development
Tilak Joshi2.6K views
JavaScript Library Overview (Ajax Exp West 2007) by jeresig
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
jeresig1.4K views
jQuery: The World's Most Popular JavaScript Library Comes to XPages by Teamstudio
jQuery: The World's Most Popular JavaScript Library Comes to XPagesjQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPages
Teamstudio4K views
Understanding Webkit Rendering by Ariya Hidayat
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
Ariya Hidayat28.8K views
Component-Oriented Web Development with Dart by C4Media
Component-Oriented Web Development with DartComponent-Oriented Web Development with Dart
Component-Oriented Web Development with Dart
C4Media2K views
jQuery - the world's most popular java script library comes to XPages by Mark Roden
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
Mark Roden7.8K views
Building Rich Internet Applications with Ext JS by Mats Bryntse
Building Rich Internet Applications  with Ext JSBuilding Rich Internet Applications  with Ext JS
Building Rich Internet Applications with Ext JS
Mats Bryntse2.6K views
Java for XPages Development by Teamstudio
Java for XPages DevelopmentJava for XPages Development
Java for XPages Development
Teamstudio10.2K views
Python - A Comprehensive Programming Language by TsungWei Hu
Python - A Comprehensive Programming LanguagePython - A Comprehensive Programming Language
Python - A Comprehensive Programming Language
TsungWei Hu1.4K views
Google Dev Day2007 by lucclaes
Google Dev Day2007Google Dev Day2007
Google Dev Day2007
lucclaes642 views
Advanced jQuery (Ajax Exp 2007) by jeresig
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)
jeresig1.3K views
Web component driven development by Gil Fink
Web component driven developmentWeb component driven development
Web component driven development
Gil Fink1.2K views
Deview 2013 mobile browser internals and trends_20131022 by NAVER D2
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
NAVER D27.7K views

Similar to Rich internet application development using the dojo toolkit

DOJO by
DOJO DOJO
DOJO Mahi Mca
545 views11 slides
Dojo training by
Dojo trainingDojo training
Dojo trainingvadivelan_k
4.9K views13 slides
Dojo Toolkit from a Flex developer's perspective by
Dojo Toolkit from a Flex developer's perspectiveDojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspectivecjolif
1.7K views15 slides
AJAX Frameworks by
AJAX FrameworksAJAX Frameworks
AJAX Frameworksshank
1.2K views18 slides
Programming in HTML5 With Java Script and CSS3 by
Programming in HTML5 With Java Script and CSS3Programming in HTML5 With Java Script and CSS3
Programming in HTML5 With Java Script and CSS3Testbells
1.3K views47 slides
What’s New & Cool in NetBeans IDE 7.x by
What’s New & Cool in NetBeans IDE 7.xWhat’s New & Cool in NetBeans IDE 7.x
What’s New & Cool in NetBeans IDE 7.xErik Gur
1.8K views51 slides

Similar to Rich internet application development using the dojo toolkit(20)

DOJO by Mahi Mca
DOJO DOJO
DOJO
Mahi Mca545 views
Dojo training by vadivelan_k
Dojo trainingDojo training
Dojo training
vadivelan_k4.9K views
Dojo Toolkit from a Flex developer's perspective by cjolif
Dojo Toolkit from a Flex developer's perspectiveDojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspective
cjolif1.7K views
AJAX Frameworks by shank
AJAX FrameworksAJAX Frameworks
AJAX Frameworks
shank1.2K views
Programming in HTML5 With Java Script and CSS3 by Testbells
Programming in HTML5 With Java Script and CSS3Programming in HTML5 With Java Script and CSS3
Programming in HTML5 With Java Script and CSS3
Testbells1.3K views
What’s New & Cool in NetBeans IDE 7.x by Erik Gur
What’s New & Cool in NetBeans IDE 7.xWhat’s New & Cool in NetBeans IDE 7.x
What’s New & Cool in NetBeans IDE 7.x
Erik Gur1.8K views
Design Pattern presentation by hoanhtran
Design Pattern presentationDesign Pattern presentation
Design Pattern presentation
hoanhtran347 views
005528214.pdf by EidTahir
005528214.pdf005528214.pdf
005528214.pdf
EidTahir2 views
whats-new-netbeans-ide-7x.pptx by GabrielSoche
whats-new-netbeans-ide-7x.pptxwhats-new-netbeans-ide-7x.pptx
whats-new-netbeans-ide-7x.pptx
GabrielSoche2 views
IBM DITA Wiki: One Year Retrospective by Don Day
IBM DITA Wiki: One Year RetrospectiveIBM DITA Wiki: One Year Retrospective
IBM DITA Wiki: One Year Retrospective
Don Day3.2K views
The Java Content Repository by nobby
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
nobby908 views
Yii Framework - Do we really need another php framework? by Joachim Eckert
Yii Framework - Do we really need another php framework?Yii Framework - Do we really need another php framework?
Yii Framework - Do we really need another php framework?
Joachim Eckert2.5K views
Django, What is it, Why is it cool? by Tom Brander
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
Tom Brander6.4K views
Dojo CRUD Components by Tom Mahieu
Dojo CRUD ComponentsDojo CRUD Components
Dojo CRUD Components
Tom Mahieu1.9K views
Building Dojo in the Cloud by James Thomas
Building Dojo in the CloudBuilding Dojo in the Cloud
Building Dojo in the Cloud
James Thomas1.3K views
Jquery dojo slides by helenmga
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
helenmga1.4K views

Recently uploaded

LLMs in Production: Tooling, Process, and Team Structure by
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team StructureAggregage
57 views77 slides
Mobile Core Solutions & Successful Cases.pdf by
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdfIPLOOK Networks
14 views7 slides
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...BookNet Canada
41 views16 slides
Initiating and Advancing Your Strategic GIS Governance Strategy by
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance StrategySafe Software
184 views68 slides
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... by
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...ShapeBlue
108 views12 slides
AI + Memoori = AIM by
AI + Memoori = AIMAI + Memoori = AIM
AI + Memoori = AIMMemoori
14 views9 slides

Recently uploaded(20)

LLMs in Production: Tooling, Process, and Team Structure by Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage57 views
Mobile Core Solutions & Successful Cases.pdf by IPLOOK Networks
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdf
IPLOOK Networks14 views
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by BookNet Canada
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada41 views
Initiating and Advancing Your Strategic GIS Governance Strategy by Safe Software
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software184 views
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... by ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue108 views
AI + Memoori = AIM by Memoori
AI + Memoori = AIMAI + Memoori = AIM
AI + Memoori = AIM
Memoori14 views
Innovation & Entrepreneurship strategies in Dairy Industry by PervaizDar1
Innovation & Entrepreneurship strategies in Dairy IndustryInnovation & Entrepreneurship strategies in Dairy Industry
Innovation & Entrepreneurship strategies in Dairy Industry
PervaizDar135 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty65 views
AIM102-S_Cognizant_CognizantCognitive by PhilipBasford
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitive
PhilipBasford21 views
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell by Fwdays
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
Fwdays14 views
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 by BookNet Canada
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
BookNet Canada44 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10146 views
"Package management in monorepos", Zoltan Kochan by Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays34 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays33 views
Cocktail of Environments. How to Mix Test and Development Environments and St... by Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
This talk was not generated with ChatGPT: how AI is changing science by Elena Simperl
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing science
Elena Simperl32 views

Rich internet application development using the dojo toolkit

  • 2. Rich Internet Application development using the Dojo Toolkit FrOSCon, Sankt Augustin, 20. August 2011 Dr. Alexander Kläser klaeser at univention dot de
  • 3. Goal of this presentation Brief overview of existing JavaScript frameworks General overview of Dojo (structure, features, resources) Know what you can do with it and whether it could help you Some details w.r.t. Rich Internat Application (RIA) development using Dojo RIA development using the Dojo Toolkit 3
  • 4. Presentation outline Overview over JavaScript Frameworks Overview over the Dojo Toolkit Dojo core features Dojo and Widgets
  • 5. Presentation outline Overview over JavaScript Frameworks Overview over the Dojo Toolkit Dojo core features Dojo and Widgets
  • 6. Our situtation @Univention Redesign of our administrative web frontend… what it can do: Domain wide configuration: users, groups, computers, ACLs, DNS, DHCP, mail, shared folders, printers, Nagios, policies, ... Computer wide configuration: system statistics, software management, process overview, ... Virtual machine management Thin client services Management system for school environments (class rooms, …) ... Solution: rewrite the client side part as RIA (w/AJAX technologies) Communication with existing server part (written in Python) A JavaScript library simplifies cross-browser compatibility RIA development using the Dojo Toolkit 6
  • 7. JavaScript libraries overview There are many (OpenSource) JavaScript libraries: Prototype, JQuery, Yahoo UI, Dojo, Mootools, ExtJS, ... Note: "JavaScript Prototype" is not necessarily the library Is the winner JQuery? RIA development using the Dojo Toolkit 7
  • 8. Our conclusions JQuery is a very popular library Great for manipulating the DOM But, no ready-to-use infrastructure for RIA (see below) ExtJS and Dojo seem to be the only libraries that offer a rich feature set: Many widgets, consistent API, module management, i18n, l10n, layout management, DOM manipulation, data abstraction, OOP, theming, data grids, build system etc. ExtJS Many features and widgets, a very good documentation with tutorials Development is closed (product of the company Sencha) Dual licensing model (commercial + LGPL) Dojo Open development License: Academic Free License v2.1 and modified BSD license Non-profit Dojo Foundation holds intellectual property rights ... so the winner is Dojo... (at least in our case) See also: http://dojotoolkit.org/reference-guide/quickstart/introduction/whydojo.html RIA development using the Dojo Toolkit 8
  • 9. Presentation outline Overview over JavaScript Frameworks Overview over the Dojo Toolkit Dojo core features Dojo and Widgets
  • 10. Statistics about Dojo (lines of code) RIA development using the Dojo Toolkit 10
  • 11. Statistics about Dojo (commits per month) RIA development using the Dojo Toolkit 11
  • 12. Statistics about Dojo (commiters per month) RIA development using the Dojo Toolkit 12
  • 13. Dojo overview Dojo consists of 3 main parts... dojo: the core Browser normalization, module loading, DOM manipulation, events, string functions, data access, drag 'n' drop, XHR calls, JSON encoding/decoding, effects/animations, OOP etc. dijit: interface widgets, advanced UI controls, template driven Form elements (calendar, dynamic combo boxes, slider etc.), dialogs, tree, layout, menus, tooltips, WYSIWYG editor etc. dojox: various extra projects, partly experimental More widgets, charts, data grid, file uploads, dynamic CSS rules, collections, syntax highlighting, sprintf, more editor plugins, more animation effects, JSON schema validation, JSON query syntax etc RIA development using the Dojo Toolkit 13
  • 14. Dojo philosophy Non-intrusive Native objects (e.g., Array, String) are not extended with additional functionality Instead extensions are provided in a clean separate namespace When possible, these extensions (functions) refer to existing, native implementations of the browser Ease of use and performance Code that is as simple as possible High-quality "full-stack" library Dojo is modular, modules are loaded when need RIA development using the Dojo Toolkit 14
  • 15. How to use Dojo <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Tutorial: Hello Dojo!</title> <!-- load Dojo and style sheets for widgets --> <script src="...dojo/dojo.js"></script> <link rel="stylesheet" type="text/css" href="...dojo/resources/dojo.css" /> <link rel="stylesheet" type="text/css" href="...dijit/themes/claro/claro.css" /> <!-- ... eventually other widget specific CSS files ... --> </head> <body class="claro"> <h1 id="greeting">Hello</h1> </body> </html> RIA development using the Dojo Toolkit 15
  • 16. Presentation outline Overview over JavaScript Frameworks Overview over the Dojo Toolkit Dojo core features Dojo and Widgets
  • 17. Dojo Base Base: no additional module needs to be loaded Execute JS functions when then DOM is ready: dojo.addOnLoad() / dojo.ready() Packaging mechanism: dojo.require(), dojo.provide() Separation of code, usage of namespaces improves reusability :) Namespaces: dojo.foo.bar → dojo/foo/bar.js Browser can load modules on demand → one module, one file No need to track dependencies (a module can load another module) A module is just a file, otherwise there is no restriction (may declare any kind of class) Modules in dojo/dijit are already compatible with the AMD API (Asynchronous Module Definition), see: http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition RIA development using the Dojo Toolkit 17
  • 18. Dojo Base (packaging mechanism) // some code... dojo.require("my.Module"); // → my/Module.js dojo.addOnLoad(function(){ var m = new my.Module(); // ... }); // in the package my/Module.js dojo.provide("my.Module"); dojo.require("my._ClassBase"); // → my/_ClassBase.js dojo.declare("my.Module", my._ClassBase, { // ... the code ... }); RIA development using the Dojo Toolkit 18
  • 19. Dojo Base (object oriented programming) Dojo provides tools to make object oriented programming in JS easier (encapsulating the prototype) Declaring classes w/inheritance: dojo.declare() Call to parent method: this.inherited(arguments) Extend existing classes: dojo.extend() Mixins: dojo.mixin(), dojo.delegate() Use of mixins A mixin provides certain functionality (methods, variables) via inheritance Mixin cannot be instantiated alone For multiple inheritance Dojo uses C3 linearization (as Python, Perl) to resolve the order in which methods are inherited RIA development using the Dojo Toolkit 19
  • 20. Dojo Base (object oriented programming 2) dojo.declare("some.Child", [ some.Parent, some.OtherParent ], { myVal: "default value", constructor: function(args){ // parent constructor is automatically called dojo.mixin(this, args); } myMethod: function() { // call overloaded parent method via this.inherited() this.inherited(arguments); // mycode... } }); var a = new some.Child(); var b = new some.Child({ myVal:"x" }); // a.myVal == "default value" // b.myVal == "x" RIA development using the Dojo Toolkit 20
  • 21. Dojo Base (signals/events, language tools) Events, signal handling Normalization of events Signal mechanism for events/function calls: dojo.[dis]connect() Publish/subscribe mechanism: dojo.publish(), dojo.subscribe() Language tools Scoping & function parameters: dojo.hitch(), dojo.partial() Type checking: dojo.is[String,Array,Function,Object,Alien]() RIA development using the Dojo Toolkit 21
  • 22. Dojo Base (signals/events, language tools 2) obj = { foo: function() { console.log('obj.foo()'); }, bar: function() { console.log('obj.bar()'); }, val: 42 }; dojo.connect(obj, 'foo', obj, 'bar'); dojo.connect(obj, 'foo', dojo.hitch(obj, function() { // we are in the scope of 'obj' console.log('signal for obj.foo()'); console.log('this.val=' + this.val); // this.val == 42 })); obj.foo(); /* output: obj.foo() obj.bar() signal for obj.foo() this.val=42 */ /* full code: http://jsfiddle.net/rTUfr/1/ */ // ... it is also possible to connect to DOM-events dojo.connect(domNode, "onclick", dojo.hitch(this, "handleClick")); RIA development using the Dojo Toolkit 22
  • 23. Dojo Base (utilities for arrays, strings, and others) Array utility functions: Iteration: dojo.forEach(), dojo.map() Filtering: dojo.filter() Condition check: dojo.every(), dojo.some() Index of a given element: dojo.indexOf() String processing: dojo.trim() A template mechanism: dojo.replace() JSON conversion: dojo.toJson(), dojo.fromJson() Browser Sniffing: dojo.isIE < 7, isFF, isWebKit ... RIA development using the Dojo Toolkit 23
  • 24. Dojo Base (Ajax calls, dojo.Deferred) Ajax wrapper functions: dojo.xhr[Get,Post,Delete,Put]() Handling of asynchronous events: dojo.Deferred Asynchronous operation abstraction Return a dojo.Deferred if the function is asynchronous Multiple dojo.Deferred can be nested and chained RIA development using the Dojo Toolkit 24
  • 25. Dojo Base (Ajax calls, dojo.Deferred 2) // xhrPost() returns an object of type dojo.Deferred var deferred = dojo.xhrPost({ url: '/echo/json/', handleAs: 'json', content: { /* ... a dict of name/string pairs ... */ } }); // register callback... then() returns a new deferred deferred = deferred.then(function(data) { var str = ''; dojo.forEach(data.messages, function(i) { str += '<div>' + i + '</div>'; }); dojo.body().innerHTML = str; return data.value; // return value is fed to next deferred }); // deferreds can be chained deferred.then(function(value) { dojo.body().innerHTML += '<div>Value: ' + value + '</div>'; }); /* full code: http://jsfiddle.net/hMREq/5/ */ RIA development using the Dojo Toolkit 25
  • 26. Dojo Base (DOM/CSS manipulation, animation) Querying DOM nodes With standard CSS3 selectors: dojo.query() By their ID: dojo.byId() Chaining of DOM manipulation: dojo.NodeList Placement in the DOM: dojo.place() Manipulation of DOM attributes: dojo.attr() Manipulation of CSS style: dojo.style() Manipulation of CSS classes: dojo.[add,remove,has]Class() Manipulation/querying of DOM node size/position: dojo.coords(), dojo.position(), dojo.[margin,content]Box() Animation: dojo.fadeIn/Out(), dojo.animateProperty() RIA development using the Dojo Toolkit 26
  • 27. Dojo Base (DOM/CSS manipulation, animation 2) // dojo.query uses standard CSS3 selectors // it returns a dojo.NodeList, a subclass of Array dojo.query("ul > li").forEach(function(n){ ... }); dojo.query("#mycontainer").addClass("mylist"); dojo.query("a").onclick(function(){ ... }); dojo.query(".styleA.styleB").map(function(n){ ... }); // calls can be chained dojo.query(".container") .addClass('newClass') .fadeIn().play(); // other kinds of manipulation dojo.style(domNode, "height", "50px"); dojo.place("<p>Hi</p>", dojo.body()); dojo.addClass(domNode, "myCssClass"); var width = dojo.marginBox(domNode).w; dojo.marginBox(domNode, {w: 300, h: 400}); dojo.fadeIn({ node: node }).play(); RIA development using the Dojo Toolkit 27
  • 28. Dojo core Core: everything else below dojo.* that needs to be loaded via dojo.require() Dojo's Dom/Widget parsing package: dojo.parser (→ see dijit) Effects library on top of base animations: dojo.fx.[sizeTo(), slideBy(), crossFade(), wipeTo(), smoothScroll()] Utility classes for internationalization: dojo.i18n More string functions: dojo.string Caching of inline text: dojo.cache() HTTP cookie manipulation: dojo.cookie() Data access/manipulation layer: dojo.store (obsolete API is dojo.data) … RIA development using the Dojo Toolkit 28
  • 29. Build system Works transparently with Package System Collects all referenced JS module files of an Dojo application and builds a single minified JS file Minification: Comments, whitespace, newlines are removed, local variables names replaced by short ones … RIA development using the Dojo Toolkit 29
  • 30. Presentation outline Overview over JavaScript Frameworks Overview over the Dojo Toolkit Dojo core features Dojo and Widgets
  • 31. Dijit dijit = Dojo widgets A widget encapsulates the DOM representation and offers a convenient object-oriented interface Events, attribute settings, GUI logic, … Widgets are created in a programmatic or a declarative manner Types of widgets: Layout widgets (border, tabs, accordion, ...) Form widgets w/validation (drop down, date pickers, popup, ...) Dialogs, Menus, … Support for i18n Widgets are themeable RIA development using the Dojo Toolkit 31
  • 32. Screenshot See: http://download.dojotoolkit.org/release-1.6.1/dojo-release-1.6.1/dijit/themes/themeTester.html RIA development using the Dojo Toolkit 32
  • 33. Widgets from markup (declarative) <div dojoType="dijit.layout.TabContainer" style="width: 100%; height: 100%;"> <div dojoType="dijit.layout.ContentPane" title="Tab 1" selected="true"> Content tab 1 </div> <div dojoType="dijit.layout.ContentPane" title="Tab 2"> Content tab 2 </div> </div> /* specify 'djConfig="parseOnLoad:true' in script tag... */ /* ... after loading, Dojo will parse the DOM tree */ /* full code: http://jsfiddle.net/H4DXH/ */ RIA development using the Dojo Toolkit 33
  • 34. Widgets from code (programmatic) dojo.require("dijit.layout.TabContainer"); dojo.require("dijit.layout.ContentPane"); dojo.addOnLoad(function() { // Create outer tab container var container = new dijit.layout.TabContainer({ style: 'height: 100%; width: 100%;' }); container.placeAt(dojo.body()); // Construct tab content panes dojo.forEach([1, 2], function(i) { container.addChild(new dijit.layout.ContentPane({ title: 'Tab ' + i, // 'content' can be HTML, DOM-node, or Dojo-widget content: 'Content tab ' + i })); }); container.startup(); }); /* Extensive use in RIA: dynamic creation/manipulation of widgets */ /* full code: http://jsfiddle.net/ghZxW/10/ */ RIA development using the Dojo Toolkit 34
  • 35. Special widget classes Base class: dijit._Widget Base class for all widgets Provides many basic features for widgets (attributes, watch, connect, DOM handling, …) Template: dijit._Templated Mixin dijit._Templated to support building dijit UI using templates Template: custom HTML code with variable/event hooks Use dojoAttachPoint and dojoAttachEvent in HTML-tags to reference DOM nodes and add event listeners Container Mixin dijit._Container to support managing children dijits Container's startup() calls children's startup() Removing a child dijit from the container doesn't destroy it RIA development using the Dojo Toolkit 35
  • 36. Widget attributes dijit._Widget.set() is the standard API to set and get attributes If necessary, custom setter/getter functions can be provided Setter functions : _setXXXAttr() Getter functions : _getXXXAttr() For the attribute email : _setEmailAttr() and _getEmailAttr() dijit._Widget.watch() notifies observers upon attribute changes Attributes are mapped to DOM nodes via attributeMap Attribute modification updates the DOM node automatically RIA development using the Dojo Toolkit 36
  • 37. Dijit life cycle – creation preamble() - originates from dojo.declare Advanced feature, return value is passed over to constructor constructor() - originates from dojo.declare Initialize and add addtitional properties postMixInProperties() - originates from dijit._Widget All member methods/variables have been mixed in from all ancestors buildRendering() - originates from dijit._Widget DOM nodes are set up postCreate() - originates from dijit._Widget Executed when widget is created and visibly placed in the DOM Children cannot be safely accessed here startup() - originates from dijit._Widget Fires when widget and all children have been created For programmatic approach: call startup() manually after adding all children RIA development using the Dojo Toolkit 37
  • 38. Dijit life cycle – destruction destroy() - originates from dijit._Widget Destroys widget itself destroyRecursive() - originates from dijit._Widget Destroys children and widget itself uninitialize() - originates from dijit._Widget Destructor method for custom clean-up See also: http://dojotoolkit.org/reference-guide/dijit/_Widget.html destroyRecursive() recursive call destroyDescendants() destroy() uninitialize() destroyRendering() custom code goes here RIA development using the Dojo Toolkit 38
  • 39. Conclusion There are many JavaScript libraries out there Yet only a few provide a good feature set for Rich Internet Application (RIA) development The Dojo Toolkit OpenSource license & open development Many features & good quality code Many widgets that are themeable Great for RIA development & pure DOM manipulation RIA development using the Dojo Toolkit 39
  • 40. The end… Thank you very much for your attention! Much more could be said… Do you have questions? Resources http://dojotoolkit.org/ http://dojotoolkit.org/api/ http://dojotoolkit.org/reference-guide/ http://dojotoolkit.org/documentation/ http://www.sitepen.com/blog/