PDA

View Full Version : Data display using GridPanel from database using Hibernate - Servlet Backend



terrorrmg
21 Jul 2013, 10:47 PM
Hi,
I am beginner in Ext JS. I want to display datas from database in gridpanel using Hibernate and Servlet. In many tutorials they explain with PHP. But I want to implement using Servlets and Hibernate FrameWork. Please Help me.

mitchellsimoens
24 Jul 2013, 4:26 AM
Do you have a response in JSON or XML coming from your server side code?

terrorrmg
24 Jul 2013, 10:38 PM
Do you have a response in JSON or XML coming from your server side code?

Thanks for your suggestion . I searched for JSON as you told and arrived at the following code. Now its showing an exception as
'java.lang.ClassCastException: mypack.UserBean cannot be cast to [Ljava.lang.Object;'

Pls Note : The listOfXrefInfo has the list of users (Checked in debug)

List<Object[]> listOfXrefInfo;
listOfXrefInfo = ub.getListOfUsers(); //Getting list of users from database
JSONObject objResulJson = new JSONObject();
JSONArray objJSONArray = new JSONArray();
JSONObject objJsonRow = null;
Object[] rows=null;

for (int index = 0; index < size; index++) {

rows=listOfXrefInfo.get(index);
objJsonRow = new JSONObject();
objJsonRow.put("userid", rows[0]);
objJsonRow.put("username",rows[1]);
objJsonRow.put("mailid",rows[2]);
objJsonRow.put("role", rows[3]);


objJSONArray.put(objJsonRow);
}
objResulJson.put("result", objJSONArray);
objResulJson.put("totalCount", listOfXrefInfo.size());


out.println(objResulJson);


Why am i getting this error? Is there any other way out?