<style type="text/css">
@import "dojoroot/dijit/themes/tundra/tundra.css";
@import "dojoroot/dojo/resources/dojo.css";
</style>
<script type="text/javascript" src="dojoroot/dojo/dojo.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit._tree.dndSource");
dojo.require("dijit.Tree");
dojo.require("dojo.parser");
dojo.require("dojo.dnd.Source");
</script>
Code language: HTML, XML (xml)
This line i.e “dojo.require“ instruct you to load the Dijit tree widget. If you don’t include this line, the markup code for the tree would not be evaluated by Dojo upon loading. You always have to include particular component you are using in your application. JSP File <body class="tundra">
<h1>Tree Drag And Drop</h1>
<div dojoType="dojo.data.ItemFileReadStore" url="TreeData" jsid="popStore">
</div>
<div dojoType="dojo.data.ItemFileWriteStore" url="newtree.json" jsid="newtree" />
</div>
<table>
<tr>
<td> <div dojoType="dijit.Tree" store="popStore" labelAttr="Tree"
checkAcceptance="stopDnd" dndController="dijit._tree.dndSource" label=“Root" jsid="ptTree">
<script type="dojo/method" event="getLabelClass" args="item"></script>
</div>
</td>
<td>
<div dojoType="dijit.Tree" jsid="newTree" label="Drop Selection Here"
class="source" store="newtree" onClick="onClick" labelAttr="name"
childrenAttr="children, items" onDndDrop="tree2CustomDrop"
dndController="dijit._tree.dndSource" checkAcceptance="dndAccept">
</div>
</td>
</tr>
</table>
<br>
<br>
<div id="selection"></div>
...
...
Code language: HTML, XML (xml)
<div dojoType="dojo.data.ItemFileWriteStore" url="newtree.json" jsid="newtree" />
This line reads the tree parents n child nodes from a json “newtree.json”.
For reading that store we have to use “ItemFileWriteStore” which is of dojotype.
<div dojoType="dijit.Tree" jsid="newTree" label="Drop Selection Here"
class="source" store="newtree" onClick="onClick" labelAttr="name" childrenAttr="children, items"
In above line we assign a dojo type to the formed jsid. And provide a method onclick for writing a required behavior of tree.
Code language: HTML, XML (xml)
Lastly we have to make an entry of servlet in StrutsConfig.xml We can form a json string in the servlet only and pass it to the client. I.e. front end. Making Ajax call from a js using DOJO is somewhat different. var dataUrl = "FetchTreeCriteria.do";
var xhrArgs = {url: dataUrl+"?"+"cell_Id="+cellId,handleAs: "json-comment-optional", preventCache: true};
var gotData = function(data){
//Fetching a data from database.
}
var rdata = dojo.xhrGet(xhrArgs);
rdata.addCallback(gotData);
Code language: JavaScript (javascript)
By using an above code you can make Ajax call and by providing a variable after question mark we can pass request parameters to the Servlet. By using xhrGet method we can make XHR call. All Dojo XHR methods are bi-directional. The only difference is the method. Using dojo.xhrPost, we use the POST method, embedding the data in the request (as opposed to the query string as with dojo.xhrGet). The data can be set directly as an object passed to the content: parameter. Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…
Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…
Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…
1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…
GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…
1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…
View Comments
very good tutorial ... it helped me a lot.
Good Tutorial..
The Download page is not working.
The link was broken. I've fixed it now. Please try again. Thanks for pointing this out.
Viral could you please put some coding stuff related to calling a servlet from using dojo..
its wonderful Tutorial..