title: Rendering ExtJS 4+ MVC application in a html div - how-to?
body: <p>All examples that I have found so far explain how to render ExtJS (4.2) MVC application within the "viewport", which in other words means full browser screen, and occupying whole HTML BODY.</p>
  
  <p>I would like to render application within the existing HTML page within named DIV, so that I can have HTML design around the application.</p>
  
  <pre><code> &lt;div id="appdiv"&gt;&lt;!-- application runs here --&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I've seen some sites with ExtJS 4 examples that use trick to render ExtJS app within the page by using IFRAME. </p>
  
  <p>Is it possible to avoid IFRAME? And, if it is, how skeleton of ExtJS 4.2 application shall look like if it will be rendered within a div. </p>
  
  <p>Notes: In ExtJS 3 I have found the solution by creating a panel as main container which renders within named div. However, version 4.2 (and possibly earlier 4.x's) suggests MVC application approach that seem far superior.</p>
  
  <p>---- Edits</p>
  
  <p>I have realised that I have to put starting points for this question.</p>
  
  <ol>
  <li>Source for this example is generated by ExtJS's CMD command that generates "application" framework skeleton.</li>
  <li>Skeleton of application is consisted of many files including engine reference, and other references, so I would not be able to include here all sources in "application" dir/folder. Skeleton of application can be done using cmd in the fashion: <code>sencha -sdk /myuserroot/Sencha/Cmd/3.1.1.274 generate app ExtGenApp /mywebroot/htdocs/extja_genapp</code> This generates files and folders and copies all necessary files in the place.</li>
  <li>"User" activity area is in "app" dir. App dir has subdirs for views, controllers, models and additional stuff. </li>
  <li>As in many other frameworks you are expected to keep folder structure so that framework can find appropriate files and initialise them.</li>
  <li>list of files:</li>
  </ol>
  
  <p>index.html (in the root of the generated application)</p>
  
  <pre><code>    &lt;!DOCTYPE HTML&gt;
      &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;ExtGenApp&lt;/title&gt;
          &lt;!-- &lt;x-compile&gt; --&gt;
              &lt;!-- &lt;x-bootstrap&gt; --&gt;
                  &lt;link rel="stylesheet" href="bootstrap.css"&gt;
                  &lt;script src="ext/ext-dev.js"&gt;&lt;/script&gt;
                  &lt;script src="bootstrap.js"&gt;&lt;/script&gt;
              &lt;!-- &lt;/x-bootstrap&gt; --&gt;
              &lt;script src="app/app.js"&gt;&lt;/script&gt;
          &lt;!-- &lt;/x-compile&gt; --&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;HTML Before&lt;/h1&gt;
          &lt;div id="appBox"&gt;&lt;/div&gt;
          &lt;h1&gt;HTML After&lt;/h1&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>app/app.js</p>
  
  <pre><code>    /*
          This file is generated and updated by Sencha Cmd. You can edit this file as
          needed for your application, but these edits will have to be merged by
          Sencha Cmd when it performs code generation tasks such as generating new
          models, controllers or views and when running "sencha app upgrade".
  
          Ideally changes to this file would be limited and most work would be done
          in other places (such as Controllers). If Sencha Cmd cannot merge your
          changes and its generated code, it will produce a "merge conflict" that you
          will need to resolve manually.
      */
  
      // DO NOT DELETE - this directive is required for Sencha Cmd packages to work.
      //@require @packageOverrides
  
  
  
      Ext.application({
          name: 'ExtGenApp',
  
          views: [
              'Main',
              'appBoxView'
          ],
  
          controllers: [
              'Main'
          ],
  
          launch: function() {
              new Ext.view.appBoxView({
                  renderTo: 'appBox'
              });;  // generates error      
          }
      });
  </code></pre>
  
  <p>note: originally there is no launch function but there is auto generate viewport (one gets that by default generator)</p>
  
  <p>app/controller/Main.js</p>
  
  <pre><code>    Ext.define('ExtGenApp.controller.Main', {
          extend: 'Ext.app.Controller'
      });
  </code></pre>
  
  <p>app/view/appBoxView.js</p>
  
  <pre><code>    Ext.define('ExtGenApp.view.appBoxView', {
          extend: 'Ext.panel.Panel',
  
          requires:[
              'Ext.tab.Panel',
              'Ext.layout.container.Border'
          ],
  
          layout: {
              type: 'border'
          },
  
          items: [{
              region: 'west',
              xtype: 'panel',
              title: 'west',
              width: 150
          },{
              region: 'center',
              xtype: 'tabpanel',
              items:[{
                  title: 'Center Tab 1'
              }]
          }]
      });
  </code></pre>
  
  <p>this shall be initial layout on the screen (AFAIK) </p>
  
  <p>and finally:</p>
  
  <p>app/view/Main.js</p>
  
  <pre><code>    Ext.define("ExtGenApp.view.Main", {
          extend: 'Ext.Component',
          html: 'Hello, World!!'
      });
  </code></pre>
  
  <p>which shall, as I understood, be the "content".</p>
  
  <p>as is, it generates an error of not founding "Ext.view.appBoxView" and how it looks to me, framework do not initialise the application.</p>