Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Dojo Interview Questions and Answers

Ques 16. What are the advantages or benefits of Dojo?

  • Associative arrays
  • Loosely typed variables
  • Regular expressions
  • Objects and classes
  • Highly evolved date, math, and string libraries
  • W3C DOM support in the Dojo

Is it helpful? Add Comment View Comments
 

Ques 17. Give a sample example on Dojo.

First you can download the dojo required files from the below link:

http://dojotutorial.org/

Example of Creating a Button

Here we are going to create a button "Hello World!". To create a button in dojo you need to a Button Widget that contains three visual states as: mouseOut, mouseOver and mouseDown. To follow the following steps for creating a dojo button widget:

<script type="text/javascript">
  // Load Dojo's code relating to widget managing functions
  dojo.require("dojo.widget.*");

  // Load Dojo's code relating to the Button widget
  dojo.require("dojo.widget.Button");
</script>

dojo.require("dojo.widget.*"): It instructs you to include the dojo widget (Not load all the widgets) for managing functions. 

dojo.require ("dojo.widget.Button"): This line instructs you to load the Dojo button widget. If you don't include this line, the markup code for the button would not be evaluated by Dojo upon loading, resulting in a plain HTML button instead of what you expect.

Insert the following code into the  HTML body:

<button dojoType="Button" widgetId="helloDojoButton" 
 onClick="helloPressed();">Hello World!</button>

The key attribute of this HTML element to notice is the dojoType attribute. This is responsible for instructing Dojo on how to process the element when the page is loading. In this case you will use a button element for the button that is used to input element - Dojo will work with either as long as the dojoType attribute is present.

widgetId="helloDojoButton":  This is replaced with id="helloDojoButton" without the functionality being affected - Dojo's widget system is smart enough to convert regular idattributes to widgetId's if no widgetId` attribute is explicitly named.

Connecting an Event to the Widget

When you click the command button then it doing something? We specify an onClick event handler for the given command button.

dojo.require("dojo.event.*");

Above code we use "dojo.event.*" that includes all events functionality of Dojo (But not all widgets). 

Following function that will called by the button when we clicked. After clicking the "helloPressed" method is called and it displays an alert message like: "Click on the Hello World Button". 

  function helloPressed()
  {
  alert('Click on the Hello World Button');
  } 

Here is the code of program:

<html>
<head>
<title>button</title>
 
<script type="text/javascript">
  dojo
.require("dojo.event.*");
  dojo
.require("dojo.widget.*");
  dojo
.require("dojo.widget.Button");
  function helloPressed
()
 
{
  alert
('Click on the Hello World Button');
 
}
  function init
()
 
{
  var helloDojoButton
= dojo.widget.byId('helloDojoButton');
  dojo
.event.connect(helloDojoButton, 'onClick', 'helloPressed')
 
}
  dojo
.addOnLoad(init);
 
</script>
</head>
<body bgcolor="#FFFFCC">
<p align="center"><font size="6" color="#800000">Welcome to Roseindia Dojo Project</font></p>
<button dojoType="Button" widgetId="helloDojoButton" onClick="helloPressed();">Hello World!</button>
<br>
</body>
</html>

Is it helpful? Add Comment View Comments
 

Ques 18. Sample code for Checkbox in Dojo framework.

Check boxes are the same as html but dojo provides more controls and styling options than a conventional check box. The checkbox contains Boolean types value either 'true' or 'false'. The following example creates a Checkbox:
<html>
  <head>
  <title>checkbox</title>
  <!-- check box -->
  <script type="text/javascript">
  dojo.require("dojo.parser");
  dojo.require("dijit.form.CheckBox");
  </script>
  </head>

  <body>
  <h2>Check box</h2>
  <input id="cb" dojotype="dijit.form.CheckBox" name="developer" 
   checked="checked" value="on" type="checkbox" />
  <label for="cb"> Are you a Dojo Developer </label> 
  </body>
</html> 

Is it helpful? Add Comment View Comments
 

Ques 19. Example of Radio Button in Dojo framework.

Radio Buttons are the same as html but dojo provides more controls and styling options than a conventional Radio button. The radio button also contains Boolean types value either 'true' or 'false'. The following example creates a Radio buttons:

<html>
  <head>
  <title>Radio</title>
  <!-- radio -->
  <script type="text/javascript">
  dojo.require("dojo.parser");
  dojo.require("dijit.form.*");
  </script>
  </head>

  <body>
  <h2>Radio button</h2>
  <input dojoType="dijit.form.RadioButton" id="val1" name="group1" 
  checked="checked" value="Programmer" type="radio" />
  <label for="val1"> Programmer </label>
  <input dojotype="dijit.form.RadioButton" id="val2"  name="group1" 
  value="Designer" type="radio" />
  <label for="val2"> Designer </label>
  <input dojotype="dijit.form.RadioButton" id="val3"  name="group1" 
   value="Developer" type="radio" />
  <label for="val3"> Developer </label> 
  </body>
</html>

Is it helpful? Add Comment View Comments
 

Ques 20. Example of Tree in Dojo Framework.

The tree is a GUI that helps to lists the hierarchical lists. The tree widget is a simple but the real power comes in the data. It represents the hierarchical structure of tree. Data is fed by the powerful dojo.dataAPI.

There are following steps for creating Dojo trees :

  • Create a rooted or rootless trees (forests)
  • Nest, each branch is independently expandible
  • Different icons for different leaf or branch classes
  • Tree data are stored in any dojo.data implementing API.
  • Events fire when users clicked on it.
  • Add, remove or disable nodes of tree.
<html>
<title>Tree</title>
<head>

  <style type="text/css">
  @import "../resources/dojo.css";
  @import "../dijit/themes/tundra/tundra.css";
  </style>

  <script type="text/javascript" src="dojo.xd.js"
djConfig="parseOnLoad: true"></script>

  <script>
  dojo.require("dojo.data.ItemFileReadStore");
  dojo.require("dijit.Tree");
  dojo.require("dojo.parser");
 </script>

</head>
<body class="tundra">
Simple Tree:<br><br>
  <div dojoType="dojo.data.ItemFileReadStore"
 url="tree.txt" jsid="popStore" />
  <div dojoType="dijit.Tree" store="popStore" 
labelAttr="sname" label="Tree"></div>
</body>
</html>

tree.txt file contains:
{ label: 'name',
identifier: 'name',
items: [
{ name:'Students', type:'cat',
children: [
{ name:'Vinod', type:'st' },
{ name:'Suman', type:'st' },
{ name:'Deepak', type:'st' }
]}

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook