Extjs - 4.1 Extending controller from a different Package - extjs4.1

I have huge application.
I would have a common folder with common extjs files across multiple extensions.
Extension folder will extend basic view from common and add its own components.
My application structure would be
common
-app
--model
--view
--store
--controller
---CommonController.js(controller file)
extension1
-app
--model
--view
--store
--controller
---Extension1Controller.js (This should extend CommonController.js)
app.js
app.js
Code:
Ext.Loader.setConfig({enabled:true});
Ext.Loader.setPath('Ext.ux', 'extjs/ux');
Ext.Loader.setPath('commonapp', '/common/app');
Ext.require([
'Ext.data.*',
'Ext.grid.*',
'Ext.tree.*'
]);
Ext.application({
name: 'NSM',
appFolder: '/extension1/app',
controllers: [
'Extension1Controller'
],
launch: function() {
Ext.create('Ext.panel.Panel', {
layout: 'fit',
renderTo:'contentContainer',
items: [
{
xtype: 'panel'
}
]
});
}
});
Extension1Controller.js
Ext.define('NSM.controller.Extension1Controller', {
extend: 'commonapp.controller.CommonController', //Extending the controller from common
init: function() {
//this.getWPPolicyStoreStore().addListener('write',this.finishedLoading, this);
console.log("in sample controller");
}
});
But extending throws following error
Uncaught Error: The following classes are not declared even if their files have been loaded: 'commonapp.controller.CommonController'. Please check the source code of their corresponding files for possible typos: '/common/app/controller/CommonController.js
Please help.

please replace extend config with 'Ext.app.Controller' instead of 'commonapp.controller.CommonController' . Because extend you are specifying what class are you going to extend. To solve your problem, just add that controller('commonapp.controller.CommonController') in Ext.application block as part of another controllers.
Thanks.

Related

How to correctly render info to handlebars template

Rendering information from my controller only passes information through to the partials included on the template.
Here is how I go about it in my login controller. After I check password and username provided I send two objects to the dashboard template that I would like to render to the page
res.render(path.join(DIST_DIR, 'dashboard.hbs'), {
user,
company
});
I can log this info and can see that it exists and it also renders out in the partials that included on dashboard.hsb, but it seems that dashboard itself is not getting the data.
My webpack setup
{
// Loads the javacript into html template provided.
// Entry point is set below in HtmlWebPackPlugin in Plugins
test: /\.hbs$/,
loader: 'handlebars-loader',
query: {
partialDirs: [
path.join(__dirname, './src/views/partials')
],
helperDirs: [
path.join(__dirname, './src/helpers')
]
}
},
new HtmlWebPackPlugin({
filename: 'dashboard.hbs',
title: 'Dashboard',
chunks: ['dashboard', 'dashboard~login', 'vendors~dashboard', 'vendors~dashboard~login'],
template: 'src/views/index/dashboard.hbs',
excludeChunks: ['server']
}),
So the page renders fine and the user information that I try to pass does show up in the partials (used by dashboard layout), but the information for the user that I want to display in the body of dashboard.hbs is always blank. I seems that information is not passed to this template.
Where am I going wrong? I would really appreciate some help here.
I was using the wrong loader. Instead of using handlebars-loader, I updated the code to use the html-loader
{
// Loads the javacript into html template provided.
// Entry point is set below in HtmlWebPackPlugin in Plugins
test: /\.hbs$/,
loader: 'html-loader',
query: {
partialDirs: [
path.join(__dirname, './src/views/partials')
],
helperDirs: [
path.join(__dirname, './src/helpers')
]
}
},
And now everything works as expected. Hope this helps someone else down the line

Configuring dojo loader paths

I'm having trouble with setting up dojo. Anything defined in the dojo config seems to correctly load using the localhost:8080/Scripts/foo.js path. However if I then try to load a module without this, say:
require(['foo'], function (_foo) { });
Then the client fails the request, with the attempted path being localhost:8080/foo.js. Obviously wrong.
What do I need to change?
// Configuration for the dojo AMD module loader
dojoConfig = {
baseUrl: "/Scripts",
packages: [{
name: 'esri',
location: 'esri'
}, {
name: 'dojo',
location: 'dojo/dojo'
}, {
name: 'dojox',
location: 'dojo/dojox'
}, {
name: 'dijit',
location: 'dojo/dijit'
}, {
name: 'jquery',
location: '.',
main: 'jquery-2.0.2'
},
Thanks.
Either of these will solve your problem:
Set dojoConfig.tlmSiblingOfDojo = false.
Define 'foo' as a package with an explicit location.
Have a look at this link : http://dojotoolkit.org/documentation/tutorials/1.6/dojo_config/
Maybe the change from packages to modulePaths would help you.
Otherwise i would define the packages on the ordinary way :
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/dojo.xd.js"></script>
regards

Sencha Touch, StoreManager is undefined

I just stated a new project in Sencha Touch 2.2.1 from the SenchaCmd. Since this is my first Sencha project I am having problems with some pretty basic stuff. I'm trying to access Ext.data.StoreManager to load a predefined store but Ext.data.StoreManager is undefined, as in it seams like the loader have not loaded this file. I have tried to fix it by adding Ext.require('Ext.data.StoreManager'); but no luck.
The project is mostly what SenchaCmd initialized with the addition of a model, a store and some changes to app/views/Main.js.
Any ideas?
Below is my Main.js:
Ext.define('DRL.view.Main', {
extend: 'Ext.dataview.List',
xtype: 'main',
requires: [
'Ext.data.Store'
],
config: {
items: [{
xtype: 'list',
itemTpl: '{teamName}',
store: Ext.data.StoreManager.lookup('teams')
}],
listeners: {
itemtap: function(self, index, target, record, e, eOpts) {
}
}
}
});
Ext.require loads files asynchronously, as well as the requires block. If you want StoreManager to be loaded before Ext.define, you should use Ext.syncRequire before the class definition.
However, there is are better and cleaner ways to achieve the same end result. For example:
app/store/TeamStore.js:
Ext.define('DRL.store.TeamStore', {
extend: 'Ext.data.Store',
model: 'DRL.model.Team' // change your model
...
});
app/store/Main.js
Ext.define('DRL.view.Main', {
...
store: 'DRL.store.TeamStore'
...
});
Then, add the DRL.store.TeamStore and DRL.view.Main to your Ext.application which should be in app.js.

Using Durandal dojoConfig and ESRI Maps

I'm trying to get ESRI maps working with Durandal and came across this link in the Durandal docs DurandalEsri
This seems to work but now Durandal is having problems finding some of my .js files. If I leave the following dojoConfig out my scripts are found but then the maps won't work.
`var dojoConfig = {
baseUrl: './',
async: true,
tlmSiblingOfDojo: true,
parseOnLoad: false,
aliases: [['text', 'dojo/text']],
packages: [
{ name: 'esri', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri' },
{ name: 'dojo', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojo' },
{ name: 'dojox', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox' },
{ name: 'dijit', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit' },
{ name: 'durandal', location: 'App/durandal' },
{ name: 'views', location: 'App/views' },
{ name: 'viewmodels', location: 'App/viewmodels' },
{ name: 'lib', location: 'App/lib' }
]
};`
My app structure looks like this:
App
durandal
lib
services
viewmodels
views
So in my shell.js file if I try to pass in 'lib/config' I get a 404 because it tried to find the config file at localhost/lib/config.js instead of localhost/dashboard/app/lib/config.js
If I pass 'dashboard/app/lib/config' to shell.js the file will be found, but it doesn't seem like I should have to specify the entire path, since 'durandal/system' and anything else under the 'durandal' folder get found correctly.
Any ideas???
I encountered a similar problem using AMD module loading with Esri. I solved it using a configuration similar to yours but with the following baseurl:
baseUrl: location.pathname.replace(/\/[^/]+$/, '') + '/path/to/app/main'
As described in Jeffrey Grajkowski's answer to my question here: https://stackoverflow.com/a/15390919/1014822
So for my scenario of Durandal + Esri + Dojo, I had to leave out the require.js file that is included with Durandal and use the dojo AMD loader. Unfortunately I have no idea what future problems this might cause.
More info can be found here

Why are my xtypes not working in Sencha touch 2.0 final?

hey i was wondering about the following problem a long time:
In my previous app i specified an xtype to my classes like so:
Ext.define('Sencha.view.Home', {
extend: 'Ext.Panel',
xtype: 'homepanel',
then in my Viewport i added in the items the xtype of 'homepanel' and of course this worked fine and the homepanel and others were displayed in my view. But after upgrading to 2.0 final i can't do this anymore? No i have to use it like this to include my homepanel in the view:
xclass: 'Sencha.view.Home'
Was this a change in the version? Do i now always must call the xclass, or am i doing something wrong with my xtype? Thanks for help!
The Sencha Framework has an alias keyword instead of xtype for the declaration
http://docs.sencha.com/touch/2-0/#!/api/Ext.Class-cfg-alias
Ext.define('MyApp.CoolPanel', {
extend: 'Ext.panel.Panel',
alias: ['widget.coolpanel'],
title: 'Yeah!'
});
// Using Ext.create
Ext.widget('widget.coolpanel');
// Using the shorthand for widgets and in xtypes
Ext.widget('panel', {
items: [
{xtype: 'coolpanel', html: 'Foo'},
{xtype: 'coolpanel', html: 'Bar'}
]
});
Which is also how EXTJS does it nowadays:
https://stackoverflow.com/a/5608766/330417
I have a Sencha Touch 2.0 app and my viewport is set up like this:
Ext.define('example.view.Viewport', {
extend: 'Ext.Container',
config: {
fullscreen: true,
id: 'mainContainer',
layout: {
type: 'card',
animation: {}//we manually set this throughout the app
},
items: [
/*
* This is a list of all of the "cards" in our app that are preloaded
*/
{ xtype: 'dashboardpanel' },
{ xtype: 'customerlist' },
{ xtype: 'loginpanel' }
]
}
});
So if yours isn't working I'm guessing something else is going on. But its hard to tell without seeing more code.
So i figured out what was wrong with my xtypes: I declared my Views in my Controller not in my App.js, as i had put them into my app.js all worked fine for me!
Thanks for your help!
Ext.define('Sencha.view.Home', {
extend: 'Ext.Panel',
alias: 'widget.homepanel'
when you want to use the alias widget 'homepanel' you just say xtype:'homepanel wherever you want to implement it
just change your container to list from panel and set the list-config as
scrollable: false,
pinHeaders: false,