• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Input as xml in dojo unable to load

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
in the following example anything mistake i am unable to load xml url.while running this getting error as lookup fail and unable to load
../WEB-INF/books.xml.please help me out as soon as possible
/

<%--
Document : xmltotreegrid
Created on : Jun 23, 2011, 11:53:07 AM
Author : JA0084604
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr">

<head>
<style type="text/css">
body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script>
dojo.require("dojox.data.XmlStore");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.CheckBox");

//This function performs some basic dojo initialization. In this case it connects the button
//onClick to a function which invokes the fetch(). The fetch function queries for all items
//and provides callbacks to use for completion of data retrieval or reporting of errors.
function init3() {
//Function to perform a fetch on the datastore when a button is clicked
function search() {
var queryObj = {};

//Build up the query from the input boxes.
var isbn = isbnBox.getValue();
if (isbn && dojo.trim(isbn) !== "") {
queryObj["isbn"] = isbn;
}

var qNode = dojo.byId("query");
if (qNode) {
qNode.innerHTML = dojo.toJson(queryObj);
}

//Callback to perform an action when the data items are starting to be returned:
function clearOldList(size, request) {
var list = dojo.byId("list3");
if (list) {
while (list.firstChild) {
list.removeChild(list.firstChild);
}
}
}

//Callback for processing a returned list of items.
function gotItems(items, request) {
var list = dojo.byId("list3");
if (list) {
var i;
for (i = 0; i < items.length; i++) {
var item = items[i];
list.appendChild(document.createTextNode("ISBN: " + bookStore.getValue(item, "isbn") + " TITLE:" + bookStore.getValue(item, "title")));
list.appendChild(document.createElement("br"));
}
}
}

//Callback for if the lookup fails.
function fetchFailed(error, request) {
alert("lookup failed.");
alert(error);
}

//Fetch the data.
bookStore.fetch({
query: queryObj,
onBegin: clearOldList,
onComplete: gotItems,
onError: fetchFailed
});

}
//Link the click event of the button to driving the fetch.
dojo.connect(button3, "onClick", search);
}
//Set the init function to run when dojo loading and page parsing has completed.
dojo.addOnLoad(init3);
</script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"
/>
</head>

<body class=" claro ">
<b>
ISBN:
</b>
<input dojoType="dijit.form.TextBox" jsId="isbnBox" value="*">
</input>
<br>
<br>
<div dojoType="dojox.data.XmlStore" jsId="bookStore" url="../WEB-INF/books.xml">
</div>
<div dojoType="dijit.form.Button" jsId="button3">
Click to search!
</div>
<br>
<br>
<b>
Query used:
</b>
<span id="query">
</span <br>
<br>
<b>
Books located:
</b>
<br>
<span id="list3">
</span>
<!-- NOTE: the following script tag is not intended for usage in real
world!! it is part of the CodeGlass and you should just remove it when
you use the code -->
<script type="text/javascript">
dojo.addOnLoad(function() {
if (document.pub) {
document.pub();
}
});
</script>
</body>

</html>

xml in WEB_INF/books.xml i created as follows
<?xml version="1.0" encoding="UTF-8"?>

<!--
Document : books.xml
Created on : June 23, 2011, 12:12 PM
Author : JA0084604
Description:
Purpose of the document follows.
-->

<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<book>
<isbn>1</isbn>
<title>Title of 1</title>
<author>Author of 1</author>
</book>
<book>
<isbn>2</isbn>
<title>Title of 2</title>
<author>Author of 2</author>
</book>
<book>
<isbn>3</isbn>
<title>Title of 3</title>
<author>Author of 3</author>
</book>
<book>
<isbn>4</isbn>
<title>Title of 4</title>
<author>Author of 4</author>
</book>
<book>
<isbn>5</isbn>
<title>Title of 5</title>
<author>Author of 5</author>
</book>
<book>
<isbn>6</isbn>
<title>Title of 6</title>
<author>Author of 6</author>
</book>
...
</books>

 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic