Results 1 to 3 of 3

Thread: retrieving data from DB using jsp and want display that data list on sencha2 screen

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default retrieving data from DB using jsp and want display that data list on sencha2 screen

    This is my jsp filein this i am displaying model_number list

    (modelnumber_list.jsp)

    Code:
    <%@page language="java" import="java.sql.*, java.util.*, java.lang.*, net.sf.json.*, org.json.simple.JSONObject" contentType="text/html, charset=UTF-8" pageEncoding="UTF-8"  %>
    
    
    <%
        try{
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/thermo?user=root&password=");
        Statement statement = connection.createStatement();
        ResultSet result = statement.executeQuery("select model_number from product");
    
    
        JSONObject json      = new JSONObject();
        JSONArray  addresses = new JSONArray();
        
            while(result.next())
            {
                addresses.add(result.getString("model_number"));
                
            }
            json.put("Addresses", addresses);
            out.println(addresses);
        
        response.setContentType("application/json");
        response.getWriter().write(json.toString());
        }
            catch (JSONException jse)
        { 
            
        }
    %>
    the JS file is blog.js .In this i want display that model_number list on sencha touch 2 screen

    Code:
    Ext.define('Sample.view.Blog',{
               extend:'Ext.navigation.View',
               xtype:'bloglist',
               config:{
                   title:'Blog',
                   iconCls:'star',
                   scrollable:true,
                   styleHtmlContent: true,
                   items:{
                       xtype: 'list',
                       itemTpl: '{model_number}',
                       store:{
                           autoLoad: true,
                           fields: ['model_number'],
                           proxy:{
                               type: 'jsonp',
                               url: 'modelnumber_list.jsp',
                               reader:{
                                   type: 'json',
                                    rootProperty: 'root'
                               }
                           }
                       }   
                   }
               }
               });
    please suggest me how to get the list. In advance Thanks......
    Last edited by mitchellsimoens; 11 Apr 2012 at 5:20 AM. Reason: added [CODE] tags

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    What is a sample of your JSON look like?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Sample is a class name and view is the folder name in Sample and blog is the name of the js file. And I added
    requires: ['Ext.data.proxy.JsonP'], after xtype:'bloglist',. even not working please direct me to get solution....

    thanks( ' . ' )

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •