I am trying to implement Ajax-JSON to achieve a functionality in my web application. I am looking for steps to start with.
I understand how the Ajax-JSON works. I just found an example of a JSON front end code and the server side Java code which receives the request from the JSON front end. But the backend java code sample contains JSON objects imported in the first line.
import.org.json.simple.*
How do i import this class into the domino server ?
I searched the forums here and there is very little info about where to start. Someone please advice me if there are any documentations related to Domino & Ajax-JSON.
Subject: Also, can you tell us more about what you’re trying to do?
AJAX is fairly simple to implement in Domino web applications.
If you’re talking about traditional Domino web apps, that is, and not xPages (if this is an xPages app, I suggest starting with xpagesblog.com). Otherwise, you’re doing one of the following:
Getting Domino View data via JSON (readviewentries will now do this, or you can use custom built views that return JSON)
Getting data from a Java or LS agent in a JSON format.
Getting external (non-domino) data in a JSON format.
All of these essentially work the same. Prepare the connection (httprequest object) initialize the connection and then handle the return via onreadstatechange. On the back-end, you build your business logic into your agent, servlet, or whatever. Then turn your response into valid JSON before the agent/servlet/program sends it back to the browser.
Again, the best resource for all of this is the web. Ajax in Action, I found to be a pretty good book, though it uses xml more than json. A good book on any of the libraries (Dojo or jQuery are both popular) will cover using JSON.
Joel, Thank you very much. I havent decided if its gonna be a standard domino web app or an xpages app. I am new to xpages. So i am not sure. My requirement below.
I need to display dynamically a list of 400-500 records from a Db2 table in web and have the user edit each row(couple of columns) and save it back to the Db2 table.
I can retrieve the records on load via a Domino agent, but
how do i efficiently display that many records on web for editing.
The records has to be displayed in a table with each row showing 4 fields (like Current price, Current discount, New price, New discount).
I need the user to be able to edit the 4 fields on each row and then save the changes back to the Db2 table
I’ve been away in Classic ASP hell for a while. However, some tips if you haven’t gotten this one done yet. Technically, it is easier to do this in xPages, or so I am told. Haven’t done anything with them myself, beyond the basic tutorials.
Using classic Domino web development techniques, the basic steps are:
Write a LS or Java agent (or a Java servlet) to obtain the records you need from the db2 database and return this data as a JSON object or XML (whichever you’re more comfortable with using print statements).
Write the javascript to set up your xhr request (this is where the libraries come in handy if you don’t want to build the code from scratch). This is the function that calls the agent or servlet using the URL.
Write a javascript callback function to deal with the return data from the server. This is where the main focus of your javascript code will be. In the handler function you want to a) receive the data from the server (it will be xml or a javascript object), b) parse the object that you now have and create the html that is to be output.
A little trick: if you simply want to build html to output to the browser and don’t need to do any calculations or modification work on the data returned from the server, you can return it as html instead of xml or json. Then you simply output it to the screen in your callback function by placing it inside a container on your page.
You should be able to find code examples in the forum… also search some of the popular lotus blog sites. Though he isn’t doing as much Domino work lately, Jake Howlett’s Codestore.net is a good place to start.
Subject: Is this a traditional Domino web app or an xPages app?
If it is the former, there is also a lot of info in the r6/7 forum. Also check the blogs… Jake Howlett’s Codestore in particular. He isn’t doing much Domino at the moment, but there are a lot of articles and postings on there about Ajax and JSON.
In particular if you take a look at the customisation of the iNotes mail interface I think this explains about JSON a little.
Also you need to be aware that when you get a Notes view via the web you can append the argument ouput=JSON to return the data in JSON format.
If you are using Java classes in your code that are not part of the standard Notes/Domino install then you need to put the relevant jar files into lib\ext before you will be able to compile or run code successfully.
Thanks Melissa. Where do i find the JSON jar files ? I searched and couldnt find a proper answer to it. I will try to find if there is an answer in the IBM red book.