Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    4
    Vote Rating
    0
    chilukuri is on a distinguished road

      0  

    Default Servlet Will response JSON object and will read json object using sencha

    Servlet Will response JSON object and will read json object using sencha


    Hi,

    I am new to Sencha touch , I am using this scripts in android sdk using phone gap frame work.

    I have implemented servlet which will respond JSON object.

    JSONServlet .java

    package com.bms;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;
    /**
    * Servlet implementation class JSONServlet
    */
    public class JSONServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public JSONServlet() {
    super();
    }
    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    PrintWriter out = response.getWriter();
    JSONArray arr = new JSONArray();
    JSONObject obj1 = new JSONObject();
    JSONObject obj2 = new JSONObject();
    JSONObject obj4 = new JSONObject();
    JSONObject obj5 = new JSONObject();
    JSONObject obj6 = new JSONObject();

    obj1.put("text", "abc");
    obj1.put("url", "abc.com");
    obj1.put("leaf", true);

    obj4.put("text", "klm");
    obj4.put("url", "klm.com");
    obj4.put("leaf", true);

    obj5.put("text", "xyz");
    obj5.put("url", "xyz.com");
    obj5.put("leaf", true);

    obj6.put("text", "pqr");
    obj6.put("url", "pqr.com");
    obj6.put("leaf", true);
    arr.add(obj1);
    arr.add(obj4);
    arr.add(obj5);
    arr.add(obj6);
    obj2.put("items",arr);

    out.println(obj2);
    //out.println(obj3.toString());


    }
    }


    and In sencha script, I am calling the servlet and try to display the servlet output (Json format)

    Ext.setup({
    onReady : function() {
    var cStore = new Ext.data.Store({
    autoLoad: true,
    proxy: {
    type: 'ajax',
    url: 'http://localhost:7001/JSONServlet/JSONServlet',
    reader: {
    type: 'json',
    root: 'items',
    totalProperty: 'results'
    }
    }
    ,fields: ['text', 'url']
    });



    }

    });


    While executing the script i got below exception

    02-14 17:39:05.553: ERROR/Web Console(320): TypeError: Result of expression 'records' [undefined] is not an object. at file:///android_asset/www/sencha-touch-debug.js:7209

    I found one more thing , request is not hitting to the server

    help me on this , how to get the data?

  2. #2
    Sencha User
    Join Date
    Sep 2010
    Posts
    3
    Vote Rating
    0
    sobrle is on a distinguished road

      0  

    Default


    First,

    your servlet should be just url: 'JSONServlet',

    I think your response type should be response.setContentType("application/json");

    I hope it helps

Similar Threads

  1. Problem in Gridpanel when there is single object in Json response.
    By anshu_gupta in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 9 Feb 2011, 3:26 AM
  2. Replies: 0
    Last Post: 15 Mar 2010, 2:39 PM
  3. how to enclose JSON object in response to Form submit error
    By angelflaree in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 22 Feb 2008, 10:47 AM

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi