Lazy Loading the Dojo Tree
Upcoming SlideShare
Loading in...5
×
 

Lazy Loading the Dojo Tree

on

  • 2,714 views

This article discusses web applications that use lazy loading to create a responsive, tree like, representation of a hierarchically structured data. Instead of getting the entire tree structure at ...

This article discusses web applications that use lazy loading to create a responsive, tree like, representation of a hierarchically structured data. Instead of getting the entire tree structure at once, a lazy load approach is used to fetch only a single node immediate subordinates on demand. This article shows how to use the Dojo libraries and the Dojo Tree widget in particular, to easily create visual representation of a hierarchical list and update it dynamically.
Graph theory is concerned with the topology of interconnected sets of nodes, abstracting away from concrete objects and the exact nature of the relation between objects. Trees are special case of graphs: Tree is a graph whose nodes are all reachable from some starting node and one that has no cycles.
Dojo Tree widget HTML code is structured as ordered set of nested containers. Visual representation of tree structure is created using CSS. Modified preorder tree traversal algorithm[1] gives a way to structure data in the very same way, as nested sets with number pairs. Starting from that point, custom JavaScript data model is created using left-right number pairs.
The client side of the sample web application is built using the Dojo JavaScript toolkit, while the server side of the sample web application is coded in the PHP programming language.
On the server side, a simple web service is created to serve XHR requests. Domain service[2] is accessing repository[3] having in backend data stored in ini formated text files.
The sample web application is developed using the NetBeans IDE.
This article focuses on creating the web service, the customization of a Dojo functionality and modeling data. The details of the Dojo libraries attributes shown in the examples are not described. Throughout the article, the reader is assumed to have a basic knowledge of the JavaScript, the Dojo and the PHP. The examples in this article are based on Dojo 1.5.0 and PHP 5.3.3.
The first part of the article was presented at LinuxTag 2010[4] conference.
Source code and UML models: https://svn.kenai.com/svn/phplazyloaddojotree~subversion
[1] http://www.ibase.ru/devinfo/DBMSTrees/sqltrees.html
[2] http://devlicio.us/blogs/casey/archive/2009/02/17/ddd-services.aspx
[3] http://devlicio.us/blogs/casey/archive/2009/02/20/ddd-the-repository-pattern.aspx
[4] http://www.linuxtag.org/2010/en/program/free-conference/popup/details-talkid364.html?talkid=364

Statistics

Views

Total Views
2,714
Views on SlideShare
2,714
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Lazy Loading the Dojo Tree Lazy Loading the Dojo Tree Presentation Transcript

    • Lazy Loading the Dojo Tree with PHP on the server side
      • We will discusses web applications that utilize the Dojo and the PHP to create visual representation of a hierarchically structured data
      • A lazy load approach is used to fetch on demand only a single node immediate subordinates data, providing responsive, tree like, dynamically updated visual representation of hierarchical list
    • Web Applications If anything about current interaction design can be called “glamorous,” it’s creating Web applications. After all, when was the last time you heard someone rave about the interaction design of a product that wasn’t on the Web? (Okay, besides the iPod.) All the cool, innovative new projects are online. Jesse James Garrett , Ajax: A New Approach to Web Applications
    • Web Applications
      • utilizing the web as a software interface
      • browser-based
      • use the browser capabilities (HTML, CSS, JavaScript)
      • resemble rich user interface, interactivity, responsiveness, and flexibility of desktop-thick clients
    • Dojo Toolkit
      • The Dojo Toolkit is an open source JavaScript framework
      • It is created to ease the rapid development of web applications
      • The Dojo has a highly flexible widget system named Dijit
      • Dijit is designed to handle a variety of use cases in a modular manner
    • The Dojo Widgets
      • HTML template
      • CSS template
      • JavaScript file for logic
      • Widgets are created to address specific use case
    • Hierarchical Data/Information
      • Abundant in everyday life to the point that they are considered as trivial
      • Many data are naturally modeled by hierarchies, but often hierarchy itself is unobserved
      • Hierarchical models are used in various domains of science and technology
    • Visualizing Hierarchies
      • Show the data structure
      • Understand data
      • Summarize large amount of data
      • The Tree widget is created to handle such use cases
    • The User Can
      • Move from summary information to detailed data
      • Focus only on something of interest
      • Set the level of detail
      • Access only desired level in the hierarch y
    • Graphs, Trees and Hierarchies
      • A graph is an abstract representation of collection of objects where pairs of objects are connected by links.
      • Vertices are mathematical abstractions representing objects in collection
      • Links connecting pairs of vertices are called edges
      • Commonly a graph is pictured as set of nodes or dots representing vertices joined by lines or curves showing edges
    • Directed and Undirected Graphs
      • No distinction can be made between the two nodes associated with each edge
      • Edges may be directed from one node to another
      • The vertices represent people in a social network
      • There is an edge between two people if they a friends
      • There is an edge when person likes someone else's photography
    • Trees
      • A tree is a connected graph with no cycles
      • A connected graph is one in which every pair of distinct vertices in the graph is connected
      • There is no way to start at some node and follow a sequence of edges that eventually return back to starting node
    • Trees (continue)
      • The tree is called rooted in the case when there is one vertex of the tree that is distinguished
      • Rooted trees are often treated as directed acyclic graphs with the edges pointing away from the root
      • Every node is the root of a subtree
      • A tree has one less edge then it has nodes
    • Hierarchies
      • A hierarchy is an ordered set or an acyclic graph
      • A directed tree with two extra properties, subordination and inheritance
    • Hierarchies (continued)
      • Some known hierarchies provide semantic meaning for the data a priori
      F-Spot Photo Manager: Organizing photos by time
    • Hierarchies (continued)
      • Hierarchies can also be automatically derived using complex algorithms that classify the data
    • The Dojo Tree Widget
      • Gives a way of representing the hierarchical nature of a structure in a graphical form
      • It is agnostic of data displayed and domain model
      • It amazingly easy and fast to put together an application and display hierarchical data
      • We hit a wall, when we need to go outside of the framework
    • Semantic Mark-Up
      • I think it’s important for a web developer to view HTML documents without any external formatting applied. That means without CSS, no JavaScript enhancement, and, if you want, no images as well; instead just the raw content. Look at it, read it through. Does it make any sense? Do you understand which parts are more important than others, which texts are headings, which parts are connected to each other?
      • If the answer is yes, the document is probably marked up in a nice understandable semantic fashion.
      Robert Nyman , Explaining Semantic Mark-up
    • The Naked Tree
      • We will not be so strict and exclude JavaScript
      • It is legal to use DOM API to “build documents, navigate their structure, and add, modify, or delete elements and content”
      • We can review generated HTML code
    • Does it make any sense?
      • Yes and No
      • Structure of HTML code has semantic meaning
      • When naked, semantic meaning is lost in representation
      • The Dojo Tree widget renders as flat, ordered list
    • The Tree Widget Structure
      • HTML code is structured as ordered set of nested containers
      • Each container represents the tree node
    • The Tree Widget Structure (continued)
      • The Tree widget is literally using CSS to create “Folders and documents” visual representation of a tree on the top of a nested set structure
    • Modeling Data
      • Trees are traditionally drawn as boxes and arrows
      • This tend to lock your mental image of a tree into a graph structure
      • Trees can be represented as nested sets as well
    • Nested Sets
      • Replace the boxes with containers
      • Nest subordinate containers inside their parents
      • Containment represents subordination
      • The root will be the largest container
      • The leaf nodes will be the innermost, empty containers
    • Preorder Tree Traversal Algorithm
      • Preorder (or depth-first) tree traversal algorithm with a modification for numbering the nodes
      • Model a tree with (left, right) nested sets with number pairs
      • These number pairs will contain the pairs of their subordinates
      • A child node is within the bounds of its parent
    • Data Structure
    • Lazy Loading
      • Lazy Loading is noting but a buzz
      • We have to undo to make it work
      • Containers that represent nodes that user did not open yet are empty
      • The HTML code is “lazy generated”
      • The Tree widget will ask only for immediate subordinate
      • Lazy loading Is natural way to do it
    • Lazy Loading (continue)
      • A large amount of data that has to be loaded to draw the entire tree
      • The user will not open every single node but will drill down till desired information is found
      • A faster rendering of the Tree widget
      • A lower network traffic
      • More HTTP requests
      • A higher server load
    • The End
      • http://kenai.com/projects/phplazyloaddojotree
      • [email_address]
      • Sample data are obtained from Wikipedia entry on Ethno-linguistic classification of the indigenous peoples of North America