View Full Version : Class instantiation Order

22 Jan 2013, 2:34 AM

I build an application in which I load several class

My home file look like this :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>ExtTop - Desktop Sample App</title>

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>resources/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>desktop/css/desktop.css" />

<!-- GC -->

<!-- <x-compile> -->
<!-- <x-bootstrap> -->
<script type="text/javascript" src="<?php echo base_url();?>resources/extjs/ext-all-debug.js"></script>
<!-- </x-bootstrap> -->
<script type="text/javascript">
'Ext.ux.desktop': '<?php echo base_url();?>desktop/js',
'Ext.ux.grid':'<?php echo base_url();?>desktop/js/grid',
'Ext.ux.IFrame': '<?php echo base_url();?>desktop/js/iframe/IFrame.js',
'Ext.ux.form.HtmlEditor.imageUpload':'<?php echo base_url();?>desktop/js/HtmlEditorImageUpload/HtmlEditorImage.js',
'Ext.ux.form.HtmlEditor.Hr': '<?php echo base_url();?>desktop/js/HtmlEditorHr/HtmlEditorHr.js',

Internal : '<?php echo base_url();?>desktop/internal',
MyDesktop: '<?php echo base_url();?>desktop/modules'



var myDesktopApp;
var user;
var base_path = "<?php echo base_url();?>";

Ext.onReady(function () {

user = new Internal.User({id:'<?php echo $this->session->userdata("idPersonne");?>'});
myDesktopApp = new MyDesktop.App();

<!-- </x-compile> -->


<a href="http://www.sencha.com" target="_blank" alt="Powered by Ext JS"


My question is How can I make that the this piece of code
myDesktopApp = new MyDesktop.App(); wait that this class
user = new Internal.User({id:'<?php echo $this->session->userdata("idPersonne");?>'}); has been fully instantiated ?

I know that I can pass the second class as a callback of the first but I don't know how to create a variable in the general namespace with this method of doing. I really need the capability to call my user class from anywhere using something like

Thanks for your answer

Best regards,


24 Jan 2013, 7:48 AM
MyDesktop.App class should require Internal.User but it depends how the MyDesktop.App is used.

25 Jan 2013, 1:29 AM
MyDesktop.App class should require Internal.User but it depends how the MyDesktop.App is used.

I try to load the class using your method so I require the class in the MyDesktop.App and then to set a user config in the init method.

Ext.define('MyDesktop.App', {
extend: 'Ext.ux.desktop.App',

requires: [



config : {


init: function() {
// custom logic before getXYZ methods get called...

this.setUser(new Internal.user({id:27}))


There is no error in the code but whatever i put in this line of code the user property of the Mydesktop.App stay null.

I also try to directly call the user class in the config property like that

user: this.setUser(new Internal.user({id:27}))

But in this case I get an error Internal not defined. the Internal.user is on the loading path and load properly see above post.

Any help is welcome

Thank you