X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..HEAD:/docs/guides/getting_started/README.js diff --git a/docs/guides/getting_started/README.js b/docs/guides/getting_started/README.js index ed35f601..63eca82f 100644 --- a/docs/guides/getting_started/README.js +++ b/docs/guides/getting_started/README.js @@ -1,3 +1 @@ -Ext.data.JsonP.getting_started({ - "guide": "

Getting Started with Ext JS 4.0

\n\n

I. Introduction

\n\n
\n\n

Ext JS 4 is by far the biggest overhaul we’ve ever made to Ext JS, and constitutes the most advanced JavaScript framework ever created. Almost every area of the framework has been upgraded, from the generated HTML to the class system. We’ve unified APIs, added incredible new capabilities, and improved the performance of the entire framework.

\n\n

With Ext JS 4 we’ve been driven by three key goals: speed, robustness and ease of use. We wanted the framework to be as fast and as robust as possible on every browser, and to be easy to learn and use. To achieve this we took the whole framework back to the drawing board, and what we’ve come back with is the fastest, most bullet-proof version of Ext JS we’ve ever created. Best of all, we’ve managed to do it while staying true to the core experience of writing apps “the Ext JS way.”

\n\n

II. Getting Started

\n\n
\n\n

1. Requirements

\n\n

1.1 Web Browsers

\n\n

Ext JS 4 supports almost any known web browsers, from Internet Explorer 6 to Chrome 11. During development, however, we recommend that you choose one of the following browsers for the best debugging experience:

\n\n\n\n\n

This tuturial assumes you are using Google Chrome 11. If you don't already have Chrome take a moment to install it, and familiarize yourself with the Chrome Developer Tools.

\n\n

1.2 Web Server

\n\n

Even though a local web server is not a requirement to use Ext JS 4, it is still highly recommended that you develop with one, since XHR over local file:// protocol has cross origin restriction on most browsers.\nIf you don't already have a local web server it is recommended that you download and install Apache HTTP Server.

\n\n\n\n\n

Once you have installed or enabled apache you can verify that Apache is running by navigating to localhost in your browser. You should see a startup page indicating that Apache HTTP Server was installed successfully and is running.

\n\n

1.3. Ext JS 4 SDK

\n\n

Download Ext JS 4 SDK. Unzip the package to a new directory called \"extjs\" within your web root directory. If you aren't sure where your web root directory is, consult the docs for your web server.\nYour web root directory may vary depending on your operating system, but if you are using Apache it is typically located at:

\n\n\n\n\n

Once you have finished installing Apache navigate to http://localhost/extjs/index.html in your browser. If an Ext JS 4 welcome page appears, you are all set.

\n\n

2. Application Structure

\n\n

2.1 Basic Structure

\n\n

Although not being mandatory, all suggestions listed below should be considered as best-practice guidelines to keep your application well organized, extensible and maintainable.\nThe following is the recommended directory structure for an Ext JS application:

\n\n
- appname\n    - app\n        - namespace\n            - Class1.js\n            - Class2.js\n            - ...\n    - extjs\n    - resources\n        - css\n        - images\n        - ...\n    - app.js\n    - index.html\n
\n\n\n\n\n

Don't worry about creating all those directories at the moment. For now lets just focus on creating the minimum amount of code necessary to get an Ext JS application up and running.\nTo do this we'll create a basic \"hello world\" Ext JS application called \"Hello Ext\". First, create the following directory and files in your web root directory.

\n\n
- helloext\n    - app.js\n    - index.html\n
\n\n

Then unzip the Ext JS 4 SDK to a directory named extjs in the helloext directory

\n\n

A typical Ext JS application is contained in a single HTML document - index.html. Open index.html and insert the following html code:

\n\n
<html>\n<head>\n    <title>Hello Ext</title>\n\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"extjs/resources/css/ext-all.css\">\n    <script type=\"text/javascript\" src=\"extjs/ext-debug.js\"></script>\n    <script type=\"text/javascript\" src=\"app.js\"></script>\n</head>\n<body></body>\n</html>\n
\n\n\n\n\n

Now you're ready to write your application code. Open app.js and insert the following JavaScript code:

\n\n
Ext.application({\n    name: 'HelloExt',\n    launch: function() {\n        Ext.create('Ext.container.Viewport', {\n            layout: 'fit',\n            items: [\n                {\n                    title: 'Hello Ext',\n                    html : 'Hello! Welcome to Ext JS.'\n                }\n            ]\n        });\n    }\n});\n
\n\n

Now open your browser and navigate to http://localhost/helloext/index.html. You should see a panel with a title bar containing the text \"Hello Ext\" and the \"welcome\" message in the panel's body area.

\n\n

2.2 Dynamic Loading

\n\n

Open the Chrome Developer Tools and click on the Console option. Now refresh the Hello Ext application. You should see a warning in the console that looks like this:

\n\n

\"testing\"

\n\n

Ext JS 4 comes with a system for dynamically loading only the JavaScript resources necessary to run your app.\nIn our example Ext.create creates an instance of Ext.container.Viewport. When Ext.create is called the loader will first check to see if Ext.container.Viewport has been defined.\nIf it is undefined the loader will try to load the JavaScript file that contains the code for Ext.container.Viewport before instantiating the viewport object. In our example the Viewport.js file gets loaded successfully, but the loader detects\nthat files are being loaded in a less-than optimal manner. Since we are loading the Viewport.js file only when an instance of Ext.container.Viewport is requested, execution of the code is stopped until that file has been loaded successfully, causing a short delay.\nThis delay would be compounded if we had several calls to Ext.create, because the application would wait for each file to load before requesting the next one.

\n\n

To fix this, we can add this one line of code above the call to Ext.application:

\n\n

Ext.require('Ext.container.Viewport');

\n\n

This will ensure that the file containing the code for Ext.container.Viewport is loaded before the application runs. You should no longer see the Ext.Loader warning when you refresh the page.

\n\n

2.4 Library Inclusion methods

\n\n

When you unzip the Ext JS 4 download, you will see the following files:

\n\n
    \n
  1. ext-debug.js - This file is only for use during development. It provides the minimum number of core Ext JS classes needed to get up and running. Any additional classes should be dynamically loaded as separate files as demonstrated above.

  2. \n
  3. ext.js - same as ext-debug.js but minified for use in production. Meant to be used in combination with your application's app-all.js file. (see section 3)

  4. \n
  5. ext-all-debug.js - This file contains the entire Ext JS library. This can be helpful for shortening your initial learning curve, however ext-debug.js is preferred in most cases for actual application development.

  6. \n
  7. ext-all.js - This is a minified version of ext-all-debug.js that can be used in production environments, however, it is not recommended since most applications will not make use of all the classes that it contains. Instead it is recommended that you create a custom build for your production environment as described in section 3.

  8. \n
\n\n\n

3. Deployment

\n\n

The newly introduced Sencha SDK Tools (download here) makes deployment of any Ext JS 4 application easier than ever. The tools allow you to generate a manifest of all JavaScript dependencies in the form of a JSB3 (JSBuilder file format) file, and create a custom build containing only the code that your application needs.

\n\n

Once you've installed the SDK Tools, open a terminal window and navigate into your application's directory.

\n\n
cd path/to/web/root/helloext\n
\n\n

From here you only need to run a couple of simple commands. The first one generates a JSB3 file:

\n\n
sencha create jsb -a index.html -p app.jsb3\n
\n\n

For applications built on top of a dynamic server-side language like PHP, Ruby, ASP, etc., you can simply replace index.html with the actual URL of your application:

\n\n
sencha create jsb -a http://localhost/helloext/index.html -p app.jsb3\n
\n\n

This scans your index.html file for all framework and application files that are actually used by the app, and then creates a JSB file called app.jsb3. Generating the JSB3 first gives us a chance to modify the generated app.jsb3 before building - this can be helpful if you have custom resources to copy, but in most cases we can immediately proceed to build the application with the second command:

\n\n
sencha build -p app.jsb3 -d .\n
\n\n

This creates 2 files based on the JSB3 file:

\n\n
    \n
  1. all-classes.js - This file contains all of your application's classes. It is not minified so is very useful for debugging problems with your built application. In our example this file is empty because our \"Hello Ext\" application does not contain any classes.

  2. \n
  3. app-all.js - This file is a minimized build of your application plus all of the Ext JS classes required to run it. It is the minified and production-ready version of all-classes.js + app.js.

  4. \n
\n\n\n

An Ext JS application will need a separate index.html for the production version of the app. You will typically handle this in your build process or server side logic, but for now let's just create a new file in the helloext directory called index-prod.html:

\n\n
<html>\n<head>\n    <title>Hello Ext</title>\n\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"extjs/resources/css/ext-all.css\">\n    <script type=\"text/javascript\" src=\"extjs/ext-debug.js\"></script>\n    <script type=\"text/javascript\" src=\"app-all.js\"></script>\n</head>\n<body></body>\n</html>\n
\n\n

Notice that ext-debug.js has been replaced with ext.js, and app.js has been replaced with app-all.js. If you navigate to http://localhost/helloext/index-prod.html in your browser, you should see the production version of the \"Hello Ext\" application.

\n\n

4. Further Reading

\n\n
    \n
  1. Class System
  2. \n
  3. MVC Application Architecture
  4. \n
  5. Layouts and Containsers
  6. \n
  7. Working with Data
  8. \n
\n\n" -}); \ No newline at end of file +Ext.data.JsonP.getting_started({"guide":"

Getting Started

\n\n

1. Requirements

\n\n

1.1 Web Browsers

\n\n

Ext JS 4 supports all major web browsers, from Internet Explorer 6 to the latest version of Google Chrome. During development, however, we recommend that you choose one of the following browsers for the best debugging experience:

\n\n\n\n\n

This tutorial assumes you are using the latest version of Google Chrome. If you don't already have Chrome take a moment to install it, and familiarize yourself with the Chrome Developer Tools.

\n\n

1.2 Web Server

\n\n

Even though a local web server is not a requirement to use Ext JS 4, it is still highly recommended that you develop with one, since XHR over local file:// protocol has cross origin restriction on most browsers.\nIf you don't already have a local web server it is recommended that you download and install Apache HTTP Server.

\n\n\n\n\n

Once you have installed or enabled Apache you can verify that it is running by navigating to localhost in your browser. You should see a startup page indicating that Apache HTTP Server was installed successfully and is running.

\n\n

1.3. Ext JS 4 SDK

\n\n

Download Ext JS 4 SDK. Unzip the package to a new directory called \"extjs\" within your web root directory. If you aren't sure where your web root directory is, consult the docs for your web server.\nYour web root directory may vary depending on your operating system, but if you are using Apache it is typically located at:

\n\n\n\n\n

Once you have finished installing Apache navigate to http://localhost/extjs/index.html in your browser. If an Ext JS 4 welcome page appears, you are all set.

\n\n

2. Application Structure

\n\n

2.1 Basic Structure

\n\n

Although not mandatory, all suggestions listed below should be considered as best-practice guidelines to keep your application well organized, extensible and maintainable.\nThe following is the recommended directory structure for an Ext JS application:

\n\n
- appname\n    - app\n        - namespace\n            - Class1.js\n            - Class2.js\n            - ...\n    - extjs\n    - resources\n        - css\n        - images\n        - ...\n    - app.js\n    - index.html\n
\n\n\n\n\n

Don't worry about creating all those directories at the moment. For now lets just focus on creating the minimum amount of code necessary to get an Ext JS application up and running.\nTo do this we'll create a basic \"hello world\" Ext JS application called \"Hello Ext\". First, create the following directory and files in your web root directory.

\n\n
- helloext\n    - app.js\n    - index.html\n
\n\n

Then unzip the Ext JS 4 SDK to a directory named extjs in the helloext directory

\n\n

A typical Ext JS application is contained in a single HTML document - index.html. Open index.html and insert the following html code:

\n\n
<html>\n<head>\n    <title>Hello Ext</title>\n\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"extjs/resources/css/ext-all.css\">\n    <script type=\"text/javascript\" src=\"extjs/ext-debug.js\"></script>\n    <script type=\"text/javascript\" src=\"app.js\"></script>\n</head>\n<body></body>\n</html>\n
\n\n\n\n\n

Now you're ready to write your application code. Open app.js and insert the following JavaScript code:

\n\n
Ext.application({\n    name: 'HelloExt',\n    launch: function() {\n        Ext.create('Ext.container.Viewport', {\n            layout: 'fit',\n            items: [\n                {\n                    title: 'Hello Ext',\n                    html : 'Hello! Welcome to Ext JS.'\n                }\n            ]\n        });\n    }\n});\n
\n\n

Now open your browser and navigate to http://localhost/helloext/index.html. You should see a panel with a title bar containing the text \"Hello Ext\" and the \"welcome\" message in the panel's body area.

\n\n

2.2 Dynamic Loading

\n\n

Open the Chrome Developer Tools and click on the Console option. Now refresh the Hello Ext application. You should see a warning in the console that looks like this:

\n\n

\"testing\"

\n\n

Ext JS 4 comes with a system for dynamically loading only the JavaScript resources necessary to run your app.\nIn our example Ext.create creates an instance of Ext.container.Viewport. When Ext.create is called the loader will first check to see if Ext.container.Viewport has been defined.\nIf it is undefined the loader will try to load the JavaScript file that contains the code for Ext.container.Viewport before instantiating the viewport object. In our example the Viewport.js file gets loaded successfully, but the loader detects\nthat files are being loaded in a less-than optimal manner. Since we are loading the Viewport.js file only when an instance of Ext.container.Viewport is requested, execution of the code is stopped until that file has been loaded successfully, causing a short delay.\nThis delay would be compounded if we had several calls to Ext.create, because the application would wait for each file to load before requesting the next one.

\n\n

To fix this, we can add this one line of code above the call to Ext.application:

\n\n

Ext.require('Ext.container.Viewport');

\n\n

This will ensure that the file containing the code for Ext.container.Viewport is loaded before the application runs. You should no longer see the Ext.Loader warning when you refresh the page.

\n\n

2.3 Library Inclusion methods

\n\n

When you unzip the Ext JS 4 download, you will see the following files:

\n\n
    \n
  1. ext-debug.js - This file is only for use during development. It provides the minimum number of core Ext JS classes needed to get up and running. Any additional classes should be dynamically loaded as separate files as demonstrated above.

  2. \n
  3. ext.js - same as ext-debug.js but minified for use in production. Meant to be used in combination with your application's app-all.js file. (see section 3)

  4. \n
  5. ext-all-debug.js - This file contains the entire Ext JS library. This can be helpful for shortening your initial learning curve, however ext-debug.js is preferred in most cases for actual application development.

  6. \n
  7. ext-all.js - This is a minified version of ext-all-debug.js that can be used in production environments, however, it is not recommended since most applications will not make use of all the classes that it contains. Instead it is recommended that you create a custom build for your production environment as described in section 3.

  8. \n
\n\n\n

3. Deployment

\n\n

The newly-introduced Sencha SDK Tools (download here) makes deployment of any Ext JS 4 application easier than ever. The tools allow you to generate a manifest of all JavaScript dependencies in the form of a JSB3 (JSBuilder file format) file, and create a custom build containing only the code that your application needs.

\n\n

Once you've installed the SDK Tools, open a terminal window and navigate into your application's directory.

\n\n
cd path/to/web/root/helloext\n
\n\n

From here you only need to run a couple of simple commands. The first one generates a JSB3 file:

\n\n
sencha create jsb -a index.html -p app.jsb3\n
\n\n

For applications built on top of a dynamic server-side language like PHP, Ruby, ASP, etc., you can simply replace index.html with the actual URL of your application:

\n\n
sencha create jsb -a http://localhost/helloext/index.html -p app.jsb3\n
\n\n

This scans your index.html file for all framework and application files that are actually used by the app, and then creates a JSB file called app.jsb3. Generating the JSB3 first gives us a chance to modify the generated app.jsb3 before building - this can be helpful if you have custom resources to copy, but in most cases we can immediately proceed to build the application with the second command:

\n\n
sencha build -p app.jsb3 -d .\n
\n\n

This creates 2 files based on the JSB3 file:

\n\n
    \n
  1. all-classes.js - This file contains all of your application's classes. It is not minified so is very useful for debugging problems with your built application. In our example this file is empty because our \"Hello Ext\" application does not contain any classes.

  2. \n
  3. app-all.js - This file is a minimized build of your application plus all of the Ext JS classes required to run it. It is the minified and production-ready version of all-classes.js + app.js.

  4. \n
\n\n\n

An Ext JS application will need a separate index.html for the production version of the app. You will typically handle this in your build process or server side logic, but for now let's just create a new file in the helloext directory called index-prod.html:

\n\n
<html>\n<head>\n    <title>Hello Ext</title>\n\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"extjs/resources/css/ext-all.css\">\n    <script type=\"text/javascript\" src=\"extjs/ext.js\"></script>\n    <script type=\"text/javascript\" src=\"app-all.js\"></script>\n</head>\n<body></body>\n</html>\n
\n\n

Notice that ext-debug.js has been replaced with ext.js, and app.js has been replaced with app-all.js. If you navigate to http://localhost/helloext/index-prod.html in your browser, you should see the production version of the \"Hello Ext\" application.

\n\n

4. Further Reading

\n\n
    \n
  1. Class System
  2. \n
  3. MVC Application Architecture
  4. \n
  5. Layouts and Containsers
  6. \n
  7. Working with Data
  8. \n
\n\n","title":"Getting Started with Ext JS 4"}); \ No newline at end of file