java program for jqgrid for beginners

4
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.getServletPa th()); // 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("record s", String.valueOf(logEntrie sCnt-1)); jqGridData.put("rows", logEntries); System.out.println("nn# Event Log Entries (" + new Date() + "):" + (logE ntriesCnt-1)); System.out.println("jqGrid JSON: n" + jqGridData.toJSONString()); aRequest.setAttribute("userdata", jqGridData.toJSONString()); aRequest.getRequestDis patcher("/jsp/eventlogte st.jsp").forward(aRequest, aResponse); } # Event Log Entries (Fri Dec 09 11:02:25 GMT 2011):10 jqGrid 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","Mo nitoring Started"]},{"id":"3","cel l":["09/12/11","10:50:55 ","Communication Estab lished"]},{"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:3 0:58","Communication Established"]},{"id": "8","cell":["09/12/11"," 10:30:58","Mon itoring Started"]},{"id":"9","cell":["09/12/11","10:21:58","Communication Establ ished"]},{"id":"10","c ell":["09/12/11","10:21: 58","Monitoring Started"]}]} <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.o r g/TR/html4/loose.dtd"> <html> <head>

Upload: karunakar

Post on 29-Oct-2015

40 views

Category:

Documents


0 download

DESCRIPTION

Beginners Jqgridjsp j2ee java program for jqgrid J2ee Program forwhich give the information on jqgridenjoy the ing=fromation regarding the j2eex,vmx.,vmddfgdfgdfgdfgdfgd

TRANSCRIPT

Page 1: Java Program For Jqgrid for beginners

7/15/2019 Java Program For Jqgrid for beginners

http://slidepdf.com/reader/full/java-program-for-jqgrid-for-beginners 1/4

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"]}]}

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>

Page 2: Java Program For Jqgrid for beginners

7/15/2019 Java Program For Jqgrid for beginners

http://slidepdf.com/reader/full/java-program-for-jqgrid-for-beginners 2/4

<meta http-equiv="Content-Type" content="application/json">

<link type="text/css" rel="stylesheet" href="/styles/cupertino/jquery-ui-1.8.14.custom.min.css"><link type="text/css" rel="stylesheet" href="/styles/ui.jqgrid.css">

<script type="text/javascript" src="/js/jquery-1.5.2.min.js"></script><script type="text/javascript" src="/js/jquery-ui-1.8.14.custom.min.js"></scri

pt>

<script type="text/javascript" src="/js/grid.locale-en.js"></script><script type="text/javascript" src="/js/jquery.jqGrid.min.js"></script>

<script type="text/javascript" src="/js/eventlog.min.js"></script>

<title>jqGrid Test</title></head><body>

<h1>jqGrid Test</h1>

<form id="formpageform" action="/eventlog" name="eventlogviewerform" method="post">

<div id="logEntries">

userdata = ${userdata}</div>

<br/><br/>

<table id="tableGrid"></table><div id="tablePager"></div>

<br/><br/>

</form>

</body></html>

 _search falsend 1323429509833page 1rows 10sidx dateentrysord asc

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>

<head>

<meta http-equiv="Content-Type" content="application/json">

<link type="text/css" rel="stylesheet" href="/styles/cupertino/jquery-ui-1.8.14.custom.min.css"><link type="text/css" rel="stylesheet" href="/styles/ui.jqgrid.css">

<script type="text/javascript" src="/js/jquery-1.5.2.min.js"></script><script type="text/javascript" src="/js/jquery-ui-1.8.14.custom.min.js"></scri

Page 3: Java Program For Jqgrid for beginners

7/15/2019 Java Program For Jqgrid for beginners

http://slidepdf.com/reader/full/java-program-for-jqgrid-for-beginners 3/4

pt>

<script type="text/javascript" src="/js/grid.locale-en.js"></script><script type="text/javascript" src="/js/jquery.jqGrid.min.js"></script>

<script type="text/javascript" src="/js/eventlog.min.js"></script>

<title>jqGrid Test</title></head><body>

<h1>jqGrid Test</h1>

<form id="formpageform" action="/eventlog" name="eventlogviewerform" method="post">

<div id="logEntries">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"]}]}</div>

<br/><br/>

<table id="tableGrid"></table><div id="tablePager"></div>

<br/><br/>

</form></body></html>

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","Communica

tion Established"]},{"id":"10","cell":["09/12/11","10:30:58","Monitoring Started"]}]}

<div id="logEntries">userdata = ${userdata}

</div>

<div id="logEntries">userdata = ${userdata}

</div>

Page 4: Java Program For Jqgrid for beginners

7/15/2019 Java Program For Jqgrid for beginners

http://slidepdf.com/reader/full/java-program-for-jqgrid-for-beginners 4/4

<div id="logEntries">userdata = {"total":"1","page":"1",...}

</div>

<script type="text/javascript">var mygriddata = {"total":"1","page":"1",...};

</script>

var mygriddata = '{"total":"1","page":"1",...}';

<script type="text/javascript">var mygriddata = {

total: "1",page: "1"//, ...

};</script>

<div id="logEntries">userdata = '${userdata}'

</div>

aResponse.setContentType("application/json");