PDA

View Full Version : MVC Architecture with Visual Studio 2010



ardiantoro
23 Nov 2011, 8:57 PM
Hi all,
I'm new to ExtJs4 and having a problem when I'm learning the MVC Architecture. I must use VS2010 because my company required it.

I just want to make a controller,
here's my code

This is the index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Account Manager</title>
<link href="/extjs/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/extjs/ext-all-debug.js"></script>
<script type="text/javascript" src="/app/app.js"></script>
</head>
<body>


</body>
</html>




This is the app.js

Ext.application({
name: 'AM',
appFolder: 'app',
controllers: ['Users']
});


This is the controller, Users.js

Ext.define("AM.controller.Users", {
extend: 'Ext.app.Controller',


init: function () {
console.log('Initialized Users! This happens before the Application launch function is called');
}
});


When I start the program, it always produce an error

Microsoft JScript runtime error: Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required class: AM.controller.Users


I want to understand the MVC concept, just declare the controller and see what's happening

vadimv
23 Nov 2011, 11:55 PM
You must enable and setup the Loader, so start to read http://docs.sencha.com/ext-js/4-0/#!/guide/getting_started
also http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Loader
Example:


Ext.Loader.setConfig({
enabled:true
,paths:{
}
});

ardiantoro
24 Nov 2011, 12:46 AM
In the getting started guide there isn't anything that mention to enable the loader.

Where do I put that code?

vadimv
24 Nov 2011, 12:58 AM
in app.js, in the second link, classes documentation for sure there's mentioned where/how about it, I suggest you to work hard with the documentation when you develop an app, also there are a bunch of examples, there's everything on sencha site for starting.

ardiantoro
24 Nov 2011, 2:16 AM
Isn't the default setup of the Loader is 'enabled' ?
I've seen the examples, and they doesn't require to set up and activate the Loader first.

Thanks for your replies :)

vadimv
24 Nov 2011, 2:21 AM
no, as I said before all answers about it are on http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Loader-cfg-enabled

ardiantoro
24 Nov 2011, 2:50 AM
I've managed to make this code up and running, looks like I misplaced the app.js inside the app folder.
After I moved the app.js outside the app folder, it works fine.
Still curious about the Ext.Loader, I don't setup anything regarding the Ext.Loader.