Results 1 to 8 of 8

Thread: Oracle Restfull webservice

  1. #1

    Default Oracle Restfull webservice

    I want to run the backend for my ExtJS application as an Oracle Restful webservice. I've created a service that returns the result as JSON file.

    I try to use the Oracle Restful Services for getting data into theExtJS application. I can create a model out of it and I am able to use the loaddata function in the Store to see the data. But when I use the model in a gridI get the error message:

    Framework Error: Uncaught Type Error: Cannot read property‘getCount’ of undefined

    Does anyone has this combination working or does somebody know what this message means

  2. #2
    Sencha User
    Join Date
    Oct 2018
    Location
    Noida
    Posts
    56
    Answers
    10

    Default

    Can you provide a fiddle for your code ?

    Seems like store is not able to read the data correctly, have you defined proxy correctly in store with root config, if you provide the code, it will be easy to solve the problem.

  3. #3

    Default

    I hope this code is sufficiënt to analyze the problem:

    Model:
    Ext.define('MyApp.model.NAW', {
    extend: 'Ext.data.Model',
    alias: 'model.naw', requires: [
    'Ext.data.field.String',
    'Ext.data.field.Integer'
    ],

    fields: [
    {
    type: 'string',
    name: 'rowid'
    },
    {
    type: 'int',
    name: 'nawnr'
    },
    {
    type: 'string',
    name: 'naam'
    }
    ]
    });


    Store:

    Ext.define('MyApp.store.MyJsonStore', {
    extend: 'Ext.data.Store',
    requires: [
    'Ext.data.proxy.Rest',
    'Ext.data.reader.Json'
    ],
    constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
    storeId: 'MyJsonStore',
    proxy: {
    type: 'rest',
    url: 'http://restserver:8888/rest/app/naw',
    reader: {
    type: 'json',
    rootProperty: 'items'
    }
    }
    }, cfg)]);
    }
    });

    View:

    Ext.define('MyApp.view.MyGrid', {
    extend: 'Ext.grid.Grid',
    alias: 'widget.mygrid',
    requires: [
    'MyApp.view.MyGridViewModel',
    'Ext.grid.column.Number'
    ],
    viewModel: {
    type: 'mygrid'
    },
    height: '100%',
    name: 'MyGrid',
    width: '100%',
    bind: {
    store: 'MyJsonStore'
    },
    columns: [
    {
    xtype: 'gridcolumn',
    dataIndex: 'rowid',
    text: 'Rowid'
    },
    {
    xtype: 'numbercolumn',
    dataIndex: 'nawnr',
    text: 'Nawnr',
    format: '00'
    },
    {
    xtype: 'gridcolumn',
    dataIndex: 'naam',
    text: 'Naam'
    }
    ]
    });


    Content of Load Data:

    [
    {
    "rowid": "AAA2T0AAGAAAQDRAAb",
    "nawnr": 220001,
    "naam": "Customer 220001",
    "id": "extModel49-1"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAf",
    "nawnr": 220002,
    "naam": "Customer 220002",
    "id": "extModel49-2"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAc",
    "nawnr": 220003,
    "naam": "Customer 220003",
    "id": "extModel49-3"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAd",
    "nawnr": 220004,
    "naam": "Customer 220004",
    "id": "extModel49-4"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAh",
    "nawnr": 220005,
    "naam": "Customer 220005",
    "id": "extModel49-5"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAg",
    "nawnr": 220006,
    "naam": "Customer 220006",
    "id": "extModel49-6"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAe",
    "nawnr": 220008,
    "naam": "Customer 220008",
    "id": "extModel49-7"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAj",
    "nawnr": 220010,
    "naam": "Customer 220010",
    "id": "extModel49-8"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAi",
    "nawnr": 220011,
    "naam": "Customer 220011",
    "id": "extModel49-9"
    },
    {
    "rowid": "AAA2T0AAGAAAQDTAAG",
    "nawnr": 220012,
    "naam": "Customer 220012",
    "id": "extModel49-10"
    },
    {
    "rowid": "AAA2T0AAGAAAQDRAAk",
    "nawnr": 220013,
    "naam": "Customer 220013",
    "id": "extModel49-11"
    },
    {
    "rowid": "AAA2T0AAGAAAQDXAAw",
    "nawnr": 230125,
    "naam": "Customer 230125",
    "id": "extModel49-12"
    },
    {
    "rowid": "AAA2T0AAGAAAQCDAAo",
    "nawnr": 270001,
    "naam": "Customer 270001",
    "id": "extModel49-13"
    },
    {
    "rowid": "AAA2T0AAGAAAQCDAAp",
    "nawnr": 270002,
    "naam": "Customer 270002",
    "id": "extModel49-14"
    },
    {
    "rowid": "AAA2T0AAGAAAQCDAAq",
    "nawnr": 270003,
    "naam": "Customer 270003",
    "id": "extModel49-15"
    },
    {
    "rowid": "AAA2T0AAGAAAPR8AAU",
    "nawnr": 270004,
    "naam": "Customer 270004",
    "id": "extModel49-16"
    },
    {
    "rowid": "AAA2T0AAGAAAQCDAAr",
    "nawnr": 270005,
    "naam": "Customer 270005",
    "id": "extModel49-17"
    },
    {
    "rowid": "AAA2T0AAGAAAQCEAAA",
    "nawnr": 270006,
    "naam": "Customer 270006",
    "id": "extModel49-18"
    },
    {
    "rowid": "AAA2T0AAGAAAQCEAAB",
    "nawnr": 270007,
    "naam": "Customer 270007",
    "id": "extModel49-19"
    },
    {
    "rowid": "AAA2T0AAGAAAQCBAAD",
    "nawnr": 270008,
    "naam": "Customer 270008",
    "id": "extModel49-20"
    },
    {
    "rowid": "AAA2T0AAGAAAQCBAAE",
    "nawnr": 270009,
    "naam": "Customer 270009",
    "id": "extModel49-21"
    },
    {
    "rowid": "AAA2T0AAGAAAQCPAAE",
    "nawnr": 270010,
    "naam": "Customer 270010",
    "id": "extModel49-22"
    },
    {
    "rowid": "AAA2T0AAGAAAQCBAAF",
    "nawnr": 270011,
    "naam": "Customer 270011",
    "id": "extModel49-23"
    },
    {
    "rowid": "AAA2T0AAGAAAQCBAAG",
    "nawnr": 270012,
    "naam": "Customer 270012",
    "id": "extModel49-24"
    },
    {
    "rowid": "AAA2T0AAGAAAQCBAAH",
    "nawnr": 270014,
    "naam": "Customer 270014",
    "id": "extModel49-25"
    }
    ]

  4. #4
    Sencha User
    Join Date
    Oct 2018
    Location
    Noida
    Posts
    56
    Answers
    10

    Default

    Hi,

    Just went through your code and realize that the problem is with your store declaration. I tried to make your code work in the below fiddle -
    https://fiddle.sencha.com/#view/editor&fiddle/2vo1

    If you are defining a store, then you don't need to override the constructor, you just need to define the configs.
    Hope that helps!

  5. #5

    Default

    As you maybe have noticed, I am totally new to Sencha. Normally I develop applcations with Oracle Forms/Reports but Oracle stopped the development of these products, so I am trying to find an alternative for developing business applications.

    I created the application in Sencha Architect, so the minimum I can define is the following:

    Ext.define('MyApp.store.MyJsonStore', {
    extend: 'Ext.data.Store',
    requires: [
    'Ext.data.proxy.Rest',
    'Ext.data.reader.Json'
    ],
    constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
    storeId: 'MyJsonStore',
    proxy: {
    type: 'rest',
    url: 'http://restserver:8888/rest/app/naw',
    reader: {
    type: 'json',
    bind: {
    rootProperty: 'items'
    }
    }
    }
    }, cfg)]);
    }
    });

    I still get the error message Uncaught TypeError: Cannot read property 'getCount' of undefined when I use the store in my grid.

  6. #6
    Sencha User
    Join Date
    Oct 2018
    Location
    Noida
    Posts
    56
    Answers
    10

    Default

    Hi,

    There are 2 changes you need to do in above code:

    1. The store you gave above is you are defining(not instantiating, means not creating object), also you don't need to override constructor there, so below is correct code -
    Ext.define('MyApp.store.MyJsonStore', {
    extend: 'Ext.data.Store',
    requires: [
    'Ext.data.proxy.Rest',
    'Ext.data.reader.Json'
    ],
    storeId: 'MyJsonStore',
    proxy: {
    type: 'rest',
    url: 'http://restserver:8888/rest/app/naw',
    reader: {
    type: 'json',
    bind: {
    rootProperty: '.' // also you don't need to give items here, as you are getting directly array from service
    }
    }
    }
    });

    2. Another thing is, as you have defined the store above, now you need to create object of that store, so when you are giving store to grid, at that time you can create new object of that store like below -
    store: new MyApp.store.MyJsonStore()

    Probably it will work now, I have updated the fiddle for those changes -
    https://fiddle.sencha.com/#view/editor&fiddle/2vo1

    When you use that in your project, you can remove static data from store and put autoLoad: true in store so it will call proxy as soon as store created.

  7. #7

    Default

    With Sencha Architect I can not find a way to change the code the way you described above. The structure is generated by Sencha Architecht and I can not override it. Which developmenttool do you use to create applications?

  8. #8
    Sencha User
    Join Date
    Oct 2018
    Location
    Noida
    Posts
    56
    Answers
    10

    Default

    I am writing code manually by hand, not using auto code generation tool. I am using visual studio code editor.

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
  •