Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
|
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 16th, 2011, 02:11 AM
Authorized User
 
Join Date: Dec 2009
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kirangentlebreeze1987
Default problem loading values to my extjs grid using json

hello experts
i am loading the values coming from database to my json object using java struts
but the values are not populating in my extjs grid
i am getting an empty grid
this is my code


this is my home.jsp
a button will be there in this page
on clicking the getvalues.jsp should come
in getvalues.jsp an extgrid should be presen with the content coming from database


Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>
<!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="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<form action="getvalues.do">

<input type="submit"></input>

</form>

</body>
</html>
Code:
public class Json extends Action {


@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
ArrayList<Employee> emp=new ArrayList<Employee>();
Myservice serve=new Myservice();
emp=serve.getemployeesservice();
Iterator<Employee> empitr=emp.iterator();
JSONArray json=new JSONArray();
JSONObject JSONobj=new JSONObject();
while(empitr.hasNext()){
JSONObject jobj=new JSONObject();
Employee empl=new Employee();
empl=empitr.next();
jobj.put("empid",empl.getEmpid());
jobj.put("empname",empl.getEmpname());
json.add(jobj);
}
JSONobj.put("employee",json);
System.out.println(JSONobj.toString());
return mapping.findForward("success");
}
}

Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<!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="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<link rel="stylesheet" type="text/css" href="css/ext-all.css"> 
<script type="text/javascript" src="js/ext-base.js"></script>
<script type="text/javascript" src="js/ext-all.js"></script>
<script type="text/javascript">

Ext.onReady(function() {
var store=new Ext.data.JsonStore({
proxy:new Ext.data.HttpProxy({
url:'http://localhost:8080/JsonExample/getvalues.do'
}),
reader:new Ext.data.JsonReader({
root:'employee',
fields:['empid','empname']
})
});
store.load();
var recs=store.getRange();
alert(recs.length);
var grid = new Ext.grid.GridPanel({
title:'employee information',


coloumns:[{header:"employeeid",width:100,dataIndex:'empid',sortable:true},
{header:"employeename",width:100,dataIndex:'empname',sortable:true}
],
storetore,
width:300,
height:300,
renderTo:Ext.getBody()
}); 


});


</script>


</head>

<body>

hi
</body>

</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem loading values to my extjs grid using json kirangentlebreeze1987 Javascript 0 March 15th, 2011 05:35 AM
strange problem - I cannot name the folder under controllers as 'json' blackhorse66 BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 1 December 29th, 2009 09:06 PM
Struts 2.2, Json data and jsp problem, help pls ish Struts 0 July 8th, 2008 04:59 AM
JSON problem with accentuation jlamas Ajax 0 September 8th, 2006 07:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.