jMaki Putting Data to Jersey

In this post I have described how to make jMaki widgets consume Jersey based web resources. In a read-only manner.

Here I would like to show how to close the circle and make jMaki widgets push an updated information back to the Jersey. Many thanks to Greg Murray who has spent some time with me on Monday to put the following piece of code together.

The most important part of it is emphasized and shows how to actually make a PUT request
using jMaki function doAjax

jmaki.subscribe("/dojo/etable/onCellEdit", function(arg) {
url: "/jMakiBackend/webresources/printers/ids/"+arg.row,
headers:[{name:"Accept", value:"application/json"}],
var i = eval("("+ar.responseText+")");
var cols = ["id", "model", "url", "location"]
eval("i." + cols[arg.column]+"='"+arg.value+"'");jmaki.doAjax({
url: "jMakiBackend/webresources/printers/ids/"+arg.row,
headers:[{name:"Content-type", value:"application/json"}],
body : jmaki.json.serialize(i)


All you need to make it work is to

  • implement the simple front-end jMaki application (as described here)
  • change the table widget to editable dojo table (replace name="yahoo.dataTable" with name="dojo.etable" in the index.jsp page. it is really simple, isn't it?)
  • and add the above mentioned snippet into your glue.js

Then you should be able to update an information in the table widget and see it updated also in the underlaying web resource representation. I have not tried, but suppose that updating printer ids shouldn't work ;-)

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.