9

Here is a simple view that i want to instantiate :

Ext.define('myapp.view.Home',{
    extend 'Ext.Panel',
    xtype : 'testpanel' ,
    config: {
        title:'home',
        iconCls:'home',
        cls : 'home',
        html: [
           '<h1> Hello Guys </h1>',
           '<p> some text goes here </p>'
        ].join("")
    }
});

i have added the view to my controller as follows :

Ext.define('myapp.controller.Main', {
    extend : 'Ext.app.Controller',
    views : ['Home'],
    ...
}

i have used the xtype in my application as follows:

items:[{
    xtype : 'testpanel'
},

Still I get this error :

Uncaught Error: [Ext.createByAlias] Cannot create an instance of unrecognized alias: widget.testpanel

I appreciate your help.

Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
user1203861
  • 1,177
  • 3
  • 15
  • 19
  • 1
    1. your namespace should start with a capital letter. 2. use alias:'widget.x'. 3. make sure that the file is actually included (do you see it in Firebug?) – Neil McGuigan May 26 '12 at 21:08

6 Answers6

16

I think you forgot to add this view in app.js - Ext.Application's "views" array. Do check.

Swar
  • 5,473
  • 3
  • 31
  • 43
4

Could it be fix by adding this ?

requires:[
  'myapp.view.Home'
]
Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
  • +1 ... yes, good point! Whenever you are creating a lazy instance of an object using xtype within an items array, that same class must have the fully qualified name of the class that defines that xtype. – JustBeingHelpful Jun 27 '13 at 06:25
3

You need to use the alias property, with the widget prefix.

Ext.define('myapp.view.Home',{
    extend 'Ext.Panel',
    alias : 'widget.testpanel' ,
    config: {
        title:'home',
        iconCls:'home',
        cls : 'home',
        html: [
            '<h1> Hello Guys </h1>',
            '<p> some text goes here </p>'
        ].join("")
    }
});
Macy Abbey
  • 3,877
  • 1
  • 20
  • 30
1

i think u need to check if files are into the right directory.

http://docs.sencha.com/ext-js/4-1/#!/guide/application_architecture

Here u could find refs to understand what could be wrong.

Check if object myapp.view.Home is in the directory app/view/Home.js

alias must be like alias : 'widget.testpanel'

and a requires:['myapp.view.Home'],

could you even post the app.js file?

Hataru
  • 94
  • 1
  • 1
  • 13
1

I got this exception when the xtype config/property value (of the component/object instance being created) didn't match the actual name of the xtype config of the class xtype config/property value. Where the instance is the lazy implementation of a component inside its parent component's items config.

JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
-1

You can fix by adding the controller class in the view.

controller: 'ControllerClass',

Tashu
  • 1