PDA

View Full Version : [CLOSED] Ext.Factory.controller undefined in Bindable



MartineNavara
2 Jun 2014, 3:35 AM
Ext version tested:

Ext 5.0.0 rev 970


Description:

After generating a new application with Sencha CMD and opening it in the browser, it throws an undefined error in the console. The error is thrown on the following code:
controller = Ext.Factory.controller(controller);
This code is in Bindable line 534. (Ext.mixin.Bindable, part of core)

The application won't show at all.


Steps to reproduce the problem:

Generate a new application with Sencha CMD
Open application in browser and show console


The result that was expected:

The new generated application should be opened in the browser.


The result that occurs instead:

The application can not be opened due to an error.

mitchellsimoens
2 Jun 2014, 4:13 AM
What version of Cmd are you using? Latest is 5.0.0.160: http://www.sencha.com/products/sencha-cmd/download

MartineNavara
2 Jun 2014, 4:52 AM
Thank you, updating Cmd solved my issue.

nmorado
4 Jun 2014, 8:59 AM
Hi Evan

It seems to happen when i upgrade from beta. I am sure I am using latest CMD 5.0.0.160

Can you give light onto what seems to be happening here?

thanks

pablo.mazorra
6 Jun 2014, 3:10 AM
The problem persist after upgrade to the lastest code:
Sencha Cmd v5.0.0.160
Sencha\Cmd\repo\extract\ext\5.0.0.97
My scenario is as follows:
I've created a fresh application.



I've created a viewport and I've changed the application line in app.js -> autoCreateViewport: 'Test.view.Viewport'.



My Application.js is


Ext.define('Test.Application', {

extend: 'Ext.app.Application',

name: 'Test',

views: [

// TODO: add views here

],

defaultToken: 'test',

controllers: [

'Root'

// TODO: add controllers here

],

stores: [

// TODO: add stores here

],

launch: function () {

// TODO - Launch the application

}

});

My Root.js is




Ext.define('Test.controller.Root', {

extend: 'Ext.app.Controller',

config : {

refs : {

mainViewport: 'viewport'

},

routes : {

'test': {

action: 'test'

}

}

},

login: function() {
debugger;
Ext.suspendLayouts();
var testMain = Ext.create('Test.view.main.Main');
this.getMainViewport().add(testMain);
Ext.resumeLayouts(true);
}
});




The error is in Bindable.js the red line (534):

applyController: function (controller) {c
controller = Ext.Fatory.controller(controller);
controller.setView(this);
return controller;
},

Any help? Thanks

MartineNavara
6 Jun 2014, 3:12 AM
Did you use 'sencha app watch' or 'sencha app refresh' after generating your application?

pablo.mazorra
6 Jun 2014, 3:31 AM
I have just perform both operations with the same result

bone
6 Jun 2014, 12:18 PM
The Ext.Factory.controller would only fail if there were no Controllers defined/loaded.

Can you see if Root.js gets loaded by the Ext.Loader? If possible, try typing "Test.controller.Root" in a console (preferrably in Chrome) and see if it actually prints something in the console.

bone
6 Jun 2014, 12:21 PM
From beta to release I found out that I had to include all ViewControllers and ViewModels in requires:[] where applicable, Ext.Factory threw the same errors as you are experiencing.

This was because the inspection/digging done by the Sencha Cmd to calculate viewcontrollers/viewmodels no longer happens. This is a move to the better, primarily because you now could move controllers and models around without having to rebuild the app.

But I'm not sure if this is the case for the problem you are having.

pablo.mazorra
10 Jun 2014, 11:33 PM
Including ViewControllers and ViewModels in requires solve my problems. Thank you very much

craig2005
15 Jun 2014, 10:04 AM
So I have this issue as well. I've just used sencha command (latest version) to build an app. I followed the directions perfectly on the website and I get this same bind error.

What files need to be updated? People are saying to update the requires[] but where? I just have a clean slate application.

Shouldn't this be fixed ASAP? I mean its a little ridiculous that you can't just use sencha command to get up and running.

craig2005
15 Jun 2014, 11:48 AM
Ok, so here's the fix.

In app->controller->Root.js

Your file should look like this:


Ext.define('MyApp.controller.Root', {
extend: 'Ext.app.Controller',
requires:['MyApp.view.main.MainController']
});


You'll need to add the requires here for your MainController.

Again, this is just to get the generic "sencha generate app -ext MyApp ./app" working.

ajin
15 Oct 2015, 8:48 AM
Production build -When I print the Ext.Factory class in my chrome debugger, I do not see a "controller" method for this class.
Testing build - The same issue as production, but the control never comes here and the application loads up. So the undefined controller method is never called.
Development build - In this case the Ex.Factor.controller() method exists.

Can some one tell me why the production build does not even have a "controller" method on Ext.Factory class? It's hard to debug this issue since it is in a compressed app.js file.

Any help is greatly appreciated.

Thanks