1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    13
    Vote Rating
    0
    zoga08 is on a distinguished road

      0  

    Default Answered: Unexpected string on getController

    Answered: Unexpected string on getController


    Hi guys,

    I'm new to ExtJs4, but I'm moving fast on my learning. I got stuck at this problem, when I call the method getController to get my controller name dynamically, I got a "Uncaught SyntaxError: Unexpected strind" and I have no idea why, because the method expects a string as parameter.

    Here is my code.

    Code:
    listeners: {
    itemclick: function(view, record, item, index, evt, options) {
       if ( record.get('leaf') ) {
          console.log("testing");
          console.log(record.raw['controllerName']);
          //var controller = iGWSystem.app.getController(record.raw['controllerName']);
          var controller = iGWSystem.app.getController('Gateway');
          console.log(controller);
          controller.init();
                                                                             
          var abaAberta = this.ownerCt.down('#tabCenter').items.findBy(function(aba){
             return aba.title === record.get('text');
          });
                                                                                 
          if (!abaAberta) {
             this.ownerCt.down('#tabCenter').add({
                title: record.get('text'),
                closable: true,
                layout: 'fit',
                autoDestroy: true,
                items: {
                   xtype: record.raw['xTypeClass']
                }
             }).show();
          } else {
             this.ownerCt.down('#tabCenter').setActiveTab(abaAberta);
          }
      }
    }
    },
    Any help will be welcome.

  2. You've got your types in a muddle:

    Code:
    Ext.define('IGWSystem.store.Gateways',{
        ...
        proxy: {
            type: 'ajax',
            ...
            reader: {
                type: 'json',
                ...
            }
        }
    });

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Answers
    541
    Vote Rating
    323
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    SyntaxError is normally thrown for invalid JavaScript, it doesn't mean you're passing a string when the method is expecting something else.

    For example, you'd get that error in Chrome if you write something like this:

    Code:
    function name('hello'){}
    I don't see anything syntactically wrong with the code you posted, nor does my IDE. You'll need to dig in with the dev tools to figure out exactly where the error is occurring. Have your debugger break on all errors. In Chrome, go to the Source tab and click on the octagonal pause symbol in the bottom toolbar to have it 'pause on exceptions'. Firebug has similar functionality if you'd rather debug there.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    13
    Vote Rating
    0
    zoga08 is on a distinguished road

      0  

    Default


    Thanks skirtle,

    I will take a look.

  5. #4
    Sencha User
    Join Date
    Oct 2012
    Posts
    13
    Vote Rating
    0
    zoga08 is on a distinguished road

      0  

    Default


    Hi skirtle,

    I tried the "pause on exceptions", but the debug pause at the extjs script "ext-all.js" and its really hard to debug it to find whats happening.

    Here's a printscreen of the error.

    extjs-error1.jpg

  6. #5
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Answers
    541
    Vote Rating
    323
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Use ext-all-dev.js during debugging, not ext-all.js.

    That error message is quite different to the one you reported originally. I suspect we're now fixing a different problem.

    Judging by that stacktrace it looks like grabbing the controller is causing it to try to instantiate some stores. That in turn causes their proxies to be created and it looks like there's a missing type for one of those proxies.

    All of this implies that your controller isn't being created until you call getController. That's a bad sign, it suggests you're synchronously loading the controller at that point.

  7. #6
    Sencha User
    Join Date
    Oct 2012
    Posts
    13
    Vote Rating
    0
    zoga08 is on a distinguished road

      0  

    Default


    The error message with the ext-all-dev.js is a lot better, but I'm new at ExtJs and I cant figure it out what is wrong.

    Here's the error message.

    Uncaught Error: [Ext.createByAlias] Cannot create an instance of unrecognized alias: proxy.undefined

    But I havent nothing called proxy.

  8. #7
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Answers
    541
    Vote Rating
    323
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Try to isolate the problem further.

    It seems to be caused by one of the stores for that controller. So the first thing to do is to establish which store is causing the problem. Remove all the stores from the stores config and add them back in one by one until you figure out which store is causing the problem.

    Once you've found the guilty store, take a look at the proxy config for that store.

  9. #8
    Sencha User
    Join Date
    Oct 2012
    Posts
    13
    Vote Rating
    0
    zoga08 is on a distinguished road

      0  

    Default


    I only have one store.

    this is my store.

    Code:
    Ext.define('IGWSystem.store.Gateways',{
        extend: 'Ext.data.Store',
        model: 'IGWSystem.model.Gateway',
        autoLoad: true,
        pageSize: 15,
        //autoLoad: { start: 0, limit: 15 },
        proxy: {
            api: {
                read: 'app/data/php/gateway/listaGateways.php'
            },
            actionMethods: {
                read: 'POST'
            },
            reader: {
                type: 'ajax',
                root: 'gateways',
                successProperty: 'success'
            }
        }
    });
    and this is my model

    Code:
    Ext.define('IGWSystem.model.Gateway',{
        extend: 'Ext.data.Model',
        fields: [{
            name: 'id'
        },{
            name: 'cifraGuia',
            type: 'string'
        },{
            name: 'ipGateway',
            type: 'string'
        },{
            name: 'descricao',
            type: 'string'
        }]
    });
    and this is my controller

    Code:
    Ext.define('IGWSystem.controller.Gateways',{
        extend: 'Ext.app.Controller',
        stores: ['Gateways'],
        models: ['Gateway'],
        views: [
            'gateway.List'
        ],
        refs: [{
            ref: 'gatewayList',
            selector: 'gatewaylist'
        }],
    
    
        init: function() {
            this.control({
                'gatewaylist': {
                    itemdbclick: this.edit
                }
            });
        },
        edit: function(){
            console.log('Double Click Test');
        }
    });
    i cant find anything wrong with them

  10. #9
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Answers
    541
    Vote Rating
    323
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    You've got your types in a muddle:

    Code:
    Ext.define('IGWSystem.store.Gateways',{
        ...
        proxy: {
            type: 'ajax',
            ...
            reader: {
                type: 'json',
                ...
            }
        }
    });

  11. #10
    Sencha User
    Join Date
    Oct 2012
    Posts
    13
    Vote Rating
    0
    zoga08 is on a distinguished road

      0  

    Default


    Thanks skirtle,

    it was a terrible mistake, everything is working now.

    Thanks

Thread Participants: 1

Tags for this Thread