7

While I am building my sencha touch 2 app using the command:- sencha app build production

but it throws an error:

[INFO] Deploying your application to /Applications/MAMP/htdocs/iPadapp/build/production
[INFO] Copied sdk/sencha-touch.js
[INFO] Copied app.js
[INFO] Copied resources/css/app.css
[INFO] Copied resources/images
[INFO] Copied resources/icons
[INFO] Copied resources/loading
[INFO] Resolving your application dependencies...
[ERROR] Error thown from your application with message: TypeError: 'undefined' is not an object

I traced the error in my code . I found out , it is due to loading my list. Here is my code

Ext.define("myProject.store.Members",{
    extend  :'Ext.data.Store',
    requires:"Ext.data.proxy.LocalStorage",
    config: {
        model   :"myProject.model.Member",
        sorters :'lastName',
        autoload:true,

        proxy: {
            type: 'localstorage',
            id  : 'mainStore'
        } 
    }
});

if I remove the line 'autoLoad: true' ( which breaks my application, then I can build the application. But my list is not loading. If I put it back the error repeats. I tried dynamically loading the list with load function , but it does not make any sense.

And here is the model.js file I amusing.

Ext.define('myProject.model.Member', {
    extend: 'Ext.data.Model',
    config: {
        fields: [
            'index',                 
            'email',
            'firstname',
            'lastname',
            'phone',
            'currentemployer',
            'currenttitle',
            'interestlevel',
            'tcgroupNames',
            'active',
            'lastlogin',
            'usertypedesc',
            'recruiternotes',
            'recruitercontact',
            'addtype',
            'usertypedesc',
            'jobtitle',
            'ipAddress',
            'recruitersource',
            'agentkeywords',
            { name: "created", type: 'date' },
            'recruiterprofileurl_linkedin',
            'recruiterprofileurl_facebook'
        ]
    }
});

Any Help is appreciated

Happy coding to all

rdougan
  • 7,217
  • 2
  • 34
  • 63
heyjii
  • 834
  • 8
  • 26
  • Are you running this on a local http server ? – Disco Apr 26 '12 at 13:29
  • Yes I am using Apache HTTP server. But I am not making any remote server interactions. Its only a local storage. – heyjii Apr 27 '12 at 05:03
  • can you paste the model.js file ? – Disco Apr 27 '12 at 11:02
  • hi @Disco , I have edited the question with model.js file. – heyjii Apr 30 '12 at 11:31
  • What OS are you running? I tried setting up a clean project using localStorage with `autoLoad` set to true and everything works and builds for me fine. Zip of the project here: http://rwd.me/GZ4P – rdougan May 12 '12 at 00:08
  • Uhm... lastName !== lastname. I hesitate to pose this as an answer, but I -think- that you would get that 'undefined...' because you capitalized wrong. – Alex May 14 '12 at 12:12
  • @Disco yeah but how to run this application on eclipse phonegap build? – prakash_d22 Jun 26 '12 at 07:35

2 Answers2

4

I have the same issue, the command builder isn't allowed to open a connection to localstorage so it crashes.

You should be able to set Ext.getStore('Members').setAutoLoad(true); in the launch: function () { of app.js.

Then your app will build and should still load the data into the store.

Adam Marshall
  • 5,895
  • 2
  • 22
  • 22
  • Hi Adam , I have tried it but no change. Anyway thanks for your reply. – heyjii Apr 26 '12 at 08:58
  • I have the exact same problem. Anyway, is it such a big problem to load the store manually to get around this? – borck May 10 '12 at 09:07
  • @adam marshall, Why should the sencha command access the localstorage? This doesn't make sense to me? – borck May 10 '12 at 09:08
  • This worked for me. heyjii, be sure to set autoLoad: false in your store and make sure no other errors are present, it should work. – M69 May 10 '12 at 16:03
  • @borck the sencha command loads the webpage with a file:// protocol the localStorage api isn't available to the file:// protocol its a browser security measure. – Adam Marshall May 11 '12 at 00:59
  • @AdamMarshall So you mean, the sencha command actually loads the webpage to determine the dependencies? I was thinking it was just a parsing involved... Now I get why it's failing, thanks! – borck May 11 '12 at 07:39
  • Yes, it does load a webpage. However, this works fine for me - which makes no sense (because your theory about security makes sense). I have created a new project which demonstrates it working fine: http://rwd.me/GZ4P – rdougan May 12 '12 at 00:10
  • @rdougan Which version of sencha command are you using? Your example project doesn't build for me using 'sencha app build production' throws: '[INFO] Copied resources/css/app.css [ERROR] Cannot call method 'forEach' of undefined' – borck May 12 '12 at 13:28
0

Note that tracing an error is better when using Chrome developer tools than using Firebug, becuase in the console of Firebug it shows no exceptions, while on the console of the Chrome developer tools it shows the uncaught exception:

Ext.getStore("Notes").load();

where the store 'Notes' doesn't exist in my case.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Rida
  • 1