I try to use dojox.data.JsonRestStore with my RESTful service. I read the articles by sitepen and dojox documentation but I can’t understand what they are all about.
My service gets requests like http://<host>/rest/relatedsuggestion?query=weath&results=3 and returns JSON
{
Suggestions: [
“weather channel”,
“weather forecast”,
“weather bbc”
]
}
It means that it can’t understand request like http://<host>/rest/relatedsuggestion/3 which are used in every tutorial. How can I make it to understand my format? And as far as I understood the responce is also unusual for this class.
In order to try JsonRestStore I wrote the following mock up page, of cource it doesn’t work and returns 4 errors “Type error: _57 is null”:
<head>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojox.data.JsonRestStore");
dojo.require("dojox.grid.DataGrid");
dojo.addOnLoad(function() {
var poStore = new dojox.data.JsonRestStore({target:"http://<host>/rest/features/relatedsuggestion"});
poStore.fetchItemByIdentity({
identity:"3433",
onItem:function(poItem){
poItem.completeOrder();
}
});
});
</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 ">
<div id="gridElement"></div>
</body>
This IBM developerWorks article might be of help: Use Dojo’s JsonRestStore with your REST services.
From your description, your service is non-standard, so you’ll need to adapt both the URLs and the response mangling to fit what
JsonRestStoreexpects. That article explains how you can do that by implementing your own service.