Ext JS 4 Cookbook— Exploring Further
We've compiled an additional 20 recipes with more useful hints and tips to help you to get the most out of Sencha's Ext JS 4 framework. Following the same format as the book, these extra recipes cover a wide variety topics and we hope they further broaden your knowledge of the framework.
Creating your applications folder structure
This recipe will give you Sencha's best-practice application folder structure. By following these guidelines, your application will be well organized, easily maintainable, and sharing components between applications will be straight-forward. In addition to these benefits you can use the Ext JS SDK tools to easily create and deploy an optimized copy of your application when you're ready to go live. We have explained how to do this in the recipe Building your Application with Sencha's SDK Tools, in Chapter 12, Advanced Ext JS for the Perfect App. To illustrate this, we'll create an application to list our project's enhancement log.
We recommend having a web server (for example, Apache or IIS) installed and running on your development computer.
Ext JS 4 Cookbook—Exploring Further
How to do it...
1. If you are not following an MVC pattern for your application use the following directory structure:
css images .…
2. If you are following an MVC pattern use the following structure:
Enhancement.js Enhancement.js Enhancement.js enhancement
How it works...
The directory enhancementLog is where you will store the application files The directory app will contain the applications classes (in their respective group's sub-folder) and will follow the naming conventions described in the There's more section The directory extjs will contain a copy of the Ext JS framework and associated files The directory resources is intended for images, additional CSS, and any other static resources the application requires index.html is the application's entry-point app.js contains the application's launch logic
Sencha has also defined some naming conventions for Ext JS 4 applications that should be followed as they will keep your code organized, well-structured, and readable. The conventions are summarized as follows:
Class naming conventions
f f f f
You are strongly encouraged to use alphanumeric characters only for naming classes Camel case for the top-level namespaces and class names only Everything else should be lowercase Acronyms should also follow the camel case convention Best practice: EnhancementLog.enhancement.views. EnhancementGrid Bad practice: Enhancement_Log.enhancement.enhancement_Grid
Source file naming conventions
Where possible, class names should map directly to the file path in which they exist One class per file only The EnhancementLog.controller.Enhancement class will exist in /enhancementLog/app/controller/Enhancement.js.
Ext JS 4 Cookbook—Exploring Further
Methods and variables naming conventions
You are strongly encouraged to use alphanumeric characters only for naming methods and variables Camel case method names and variables Example: getEnhancementStore() or decodeEnhancementJson()
Properties naming conventions
You are strongly encouraged to use alphanumeric characters only for naming properties Camel case properties that are not static constants Static constants should always be uppercase Example: Ext.MessageBox.YES = "Yes"
The Dynamically Loading Ext JS Classes recipe in Chapter 1, Classes, Object-Oriented Principles, and Structuring your Application, as this folder...
Please join StudyMode to read the full document