jqgrid j2ee jav a program for

Download Jqgrid J2EE Jav a Program for

If you can't read please download the document

Upload: karunakar

Post on 03-Jan-2016

22 views

Category:

Documents


0 download

DESCRIPTION

java Prgoram for jqgrid using the servlet program,

TRANSCRIPT

jqGrid not being populated with JSON data from Java Servlet@Override protected void doGet(HttpServletRequest aRequest, HttpServletResponse aResponse, Hashtable aQueryData, LocaleData aLocale) throws ServletException, IOException { System.out.println("doGet(): Received Request: " + aRequest.getServletPath()); // jqGrid expects the JSON data in a predefined format: // { // "total": "xxx", // "page": "yyy", // "records": "zzz", // "rows" : [ // {"id" :"1", "cell" :["cell11", "cell12", "cell13"]}, // {"id" :"2", "cell":["cell21", "cell22", "cell23"]}, // ... // ] // } // Calling getLogEntries() method populates logEntries & logEntriesCnt. // logEntries contains the "rows" data as specified above. // For now I am testing with 10 rows of data. getLogEntries(aLocale); JSONObject jqGridData = new JSONObject(); jqGridData.put("total", "1"); jqGridData.put("page", "1"); jqGridData.put("records", String.valueOf(logEntriesCnt-1)); jqGridData.put("rows", logEntries); System.out.println("nn# Event Log Entries (" + new Date() + "):" + (logEntriesCnt-1)); System.out.println("jqGrid JSON: n" + jqGridData.toJSONString()); aRequest.setAttribute("userdata", jqGridData.toJSONString()); aRequest.getRequestDispatcher("/jsp/eventlogtest.jsp").forward(aRequest, aResponse); }# Event Log Entries (Fri Dec 09 11:02:25 GMT 2011):10jqGrid JSON: {"total":"1","page":"1","records":"10","rows":[{"id":"1","cell":["09/12/11","11:01:52","Communication Established"]},{"id":"2","cell":["09/12/11","11:01:52","Monitoring Started"]},{"id":"3","cell":["09/12/11","10:50:55","Communication Established"]},{"id":"4","cell":["09/12/11","10:50:55","Monitoring Started"]},{"id":"5","cell":["09/12/11","10:36:57","Communication Established"]},{"id":"6","cell":["09/12/11","10:36:57","Monitoring Started"]},{"id":"7","cell":["09/12/11","10:30:58","Communication Established"]},{"id":"8","cell":["09/12/11","10:30:58","Monitoring Started"]},{"id":"9","cell":["09/12/11","10:21:58","Communication Established"]},{"id":"10","cell":["09/12/11","10:21:58","Monitoring Started"]}]} jqGrid Test userdata = ${userdata} _search falsend 1323429509833page 1rows 10sidx dateentrysord asc jqGrid Test userdata = {"total":"1","page":"1","records":"10","rows":[{"id":"1","cell":["09/12/11","11:18:13","Communication Established"]},{"id":"2","cell":["09/12/11","11:18:13","Monitoring Started"]},{"id":"3","cell":["09/12/11","11:01:52","Communication Established"]},{"id":"4","cell":["09/12/11","11:01:52","Monitoring Started"]},{"id":"5","cell":["09/12/11","10:50:55","Communication Established"]},{"id":"6","cell":["09/12/11","10:50:55","Monitoring Started"]},{"id":"7","cell":["09/12/11","10:36:57","Communication Established"]},{"id":"8","cell":["09/12/11","10:36:57","Monitoring Started"]},{"id":"9","cell":["09/12/11","10:30:58","Communication Established"]},{"id":"10","cell":["09/12/11","10:30:58","Monitoring Started"]}]} jqGrid Testuserdata = {"total":"1","page":"1","records":"10","rows":[{"id":"1","cell":["09/12/11","11:18:13","Communication Established"]},{"id":"2","cell":["09/12/11","11:18:13","Monitoring Started"]},{"id":"3","cell":["09/12/11","11:01:52","Communication Established"]},{"id":"4","cell":["09/12/11","11:01:52","Monitoring Started"]},{"id":"5","cell":["09/12/11","10:50:55","Communication Established"]},{"id":"6","cell":["09/12/11","10:50:55","Monitoring Started"]},{"id":"7","cell":["09/12/11","10:36:57","Communication Established"]},{"id":"8","cell":["09/12/11","10:36:57","Monitoring Started"]},{"id":"9","cell":["09/12/11","10:30:58","Communication Established"]},{"id":"10","cell":["09/12/11","10:30:58","Monitoring Started"]}]} userdata = ${userdata} userdata = ${userdata} userdata = {"total":"1","page":"1",...}var mygriddata = '{"total":"1","page":"1",...}'; userdata = '${userdata}'aResponse.setContentType("application/json");