jurisv / nodejs.extdirect

Ext.Direct connector for node.js (npm module)
41 stars 16 forks source link

Ext.namespace is not a function error #40

Closed vredevoogda closed 7 years ago

vredevoogda commented 7 years ago

Jurisv,

I have been using you direct example for awhile and it is great. I recently upgraded an extjs 5.1.0 project using direct to extjs 6.5.0. I also upgraded my extjs direct node server from 1.0 to your new 2.0 version. I do see that your version says extjs 5. I was hoping to use it with the latest extjs.

In the directapi string that returns from the server I am getting this error:

Uncaught TypeError: Ext.namespace is not a function at directapi: 1

Ext.namespace("ExtRemote");ExtRemote.REMOTING_API={"url":"http://00.000.000.000:3000/direct","namespace":"ExtRemote","type":"remoting","actions":{"DXApprvdDevs":[{"name":"submit","len":1,"formHandler":true},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXClientConfig":[{"name":"create","len":1,"formHandler":true},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXClientList":[{"name":"read","len":1}],"DXCurTests":[{"name":"submit","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXFacForm":[{"name":"read","len":1},{"name":"create","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXFacType":[{"name":"read","len":1}],"DXFacilityUse":[{"name":"read","len":1}],"DXHazForm":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXHazardType":[{"name":"read","len":1}],"DXInvoiceFixedWidth":[{"name":"read","len":1}],"DXInvoiceHist":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXInvoiceQue":[{"name":"create","len":1},{"name":"createNoInvNo","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXInvoiceSum":[{"name":"read","len":1}],"DXIssue":[{"name":"create","len":1}],"DXLog":[{"name":"create","len":1}],"DXLoginForm":[{"name":"submit","len":1,"formHandler":true}],"DXNotes":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXNoticeActive":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXNoticeHist":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXNoticeQue":[{"name":"read","len":1},{"name":"create","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXPriceCfg":[{"name":"read","len":1}],"DXRoles":[{"name":"submit","len":1,"formHandler":true},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXScriptLog":[{"name":"submit","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXSession":[{"name":"create","len":1}],"DXSurveyFreq":[{"name":"read","len":1}],"DXSurveyVltns":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXSurveys":[{"name":"read","len":1},{"name":"create","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXSurveysSig":[{"name":"submit","len":1}],"DXSync":[{"name":"cnnctnChk","len":1},{"name":"create","len":1},{"name":"doesExist","len":1}],"DXSyncError":[{"name":"create","len":1}],"DXSyncHist":[{"name":"create","len":1}],"DXTestFreq":[{"name":"read","len":1}],"DXTestLog":[{"name":"create","len":1}],"DXTests":[{"name":"read","len":1},{"name":"create","len":1},{"name":"update","len":1},{"name":"destroy","len":1}],"DXTestsSig":[{"name":"submit","len":1},{"name":"update","len":1}],"DXUsers":[{"name":"read","len":1},{"name":"submit","len":1,"formHandler":true},{"name":"createNoForm","len":1},{"name":"update","len":1},{"name":"destroy","len":1},{"name":"namecnt","len":1}],"DXWrkActive":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1},{"name":"destroyId","len":1}],"DXWrkHist":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1},{"name":"destroy","len":1}]}}

Any suggestions you can give me would be greatly appreciated. Thanks

jurisv commented 7 years ago

How are you calling the server script? This seems to be a timing issue as direct API is being executed before Ext is available. Did you look up the example I recommended to you in Sencha forum? It's using Ext 6.5 and it shows best practices of directapi.

jurisv commented 7 years ago

Also something is wrong with your server address config, as it shows 00.000.000.000 in the payload.

jurisv commented 7 years ago

Here is the relevant section in the example https://github.com/sencha-extjs-examples/Coworkee/blob/master/client/app/view/viewport/ViewportController.js

vredevoogda commented 7 years ago

Thank you for responding.

I manually changed the server ip to 0's, to remove my specific server ip, just to be safe.

Here is my app.json file. I change my extdirect node server here. I am currently testing on local

"js": [ { "path": "app.js", "bundle": true }, { // local node "path": "http://localhost:3000/directapi",

        // test node 
        //"path": "http://ec2-00-000-000-000.compute-1.amazonaws.com:3000/directapi",

        // production node
        //"path": "http://ec2-000-00-000-000.compute-1.amazonaws.com:3000/directapi",

        "remote": true,
        "update": "full"
    }

Here is my application.js file:

Ext.define('BackflowApp.Application', { extend: 'Ext.app.Application',

name: 'BackflowApp',

requires:[
    'Ext.direct.*',
    'Ext.data.proxy.Direct'
],

launch: function () {
    Ext.direct.Manager.addProvider(ExtRemote.REMOTING_API);
},

onAppUpdate: function () {
    Ext.Msg.confirm('Application Update', 'This application has an update, reload?',
        function (choice) {
            if (choice === 'yes') {
                window.location.reload();
            }
        }
    );
}

});

jurisv commented 7 years ago

To keep it simple, the adjustments you have to make are as follows:

mixins: [ 'Ext.mixin.Mashup' ],
requiredScripts: [ '/directapi' ],

Make sure to scrum over the readme of the example: https://github.com/sencha-extjs-examples/Coworkee/tree/master/client#architecture

Hope this helps.

vredevoogda commented 7 years ago

Thank you for those examples. They fixed the app connection issues.

I have looked at the server provided with the coworkee example. It has a lot of new functionality and requires a rewrite of our apis. I am attempting to get your 2.0 server working with extjs 6.5 as I used it for 2 years (with extjs 5.1.0) and it worked great.

I am having several issues, possibly all related:

I am using the existing client code and apis that were functioning prior to upgrade.

Thank you for any assistance.

jurisv commented 7 years ago

Coworkee example provided by Sencha is indeed more complex and show deeper integration with backend. As far as existing backend, unless you are upgrading infrastructure, no changes should be needed.

I plan to create new set of examples that would mimic base functionality inline in what i had for versions 4 and 5 in the past. As Sencha example is leveraging modern toolkit, mine will focus on classic toolkit and should cover your use case.