<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Bleext</title>
	
	<link>http://www.bleext.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Sun, 13 May 2012 06:10:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Bleext" /><feedburner:info uri="bleext" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Loading classes dynamically with ExtJS4</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/Fc5aV-bi5-M/</link>
		<comments>http://www.bleext.com/blog/loading-classes-dynamically-with-extjs4/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 09:00:03 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=140</guid>
		<description><![CDATA[Ext JS 4 introduces a simple way to load classes on demand, this will allow us to optimize the...]]></description>
			<content:encoded><![CDATA[<p>Ext JS 4 introduces a simple way to load classes on demand, this will allow us to optimize the initial load of our application and only load the modules when the user requests.<br />
<span id="more-140"></span><br />
In a previous tutorial I talked about <a href="http://www.bleext.com/blog/naming-conventions">the conventions we should follow</a> in order to use in a very simple way the Ext.Loader, today I will show how to use it on our own project.</p>
<h3>Configure the Paths</h3>
<p>First we must define where our classes will be located, in languages ​​like Java there is something called &#8220;classpath&#8221; which is where the classes we created are, in Ext4 there is a similar concept and to define the &#8220;path&#8221; we have to do the following:</p>
<pre name="code" class="prettyprint">
Ext.Loader.setConfig({
	enabled	: true,
	paths	: {
		Bleext	: &#34;js&#47;Bleext&#34;
	}
});
</pre>
<p>In the previous code we enabled the Loader and assign it a path, from now on every time we load a class whose main namespace is &#8220;Bleext&#8221;, the Loader will look for the file in the folder &#8220;js/Bleext&#8221;.</p>
<p>We can also define more paths, for example:</p>
<pre name="code" class="prettyprint">
Ext.Loader.setConfig({
	enabled	: true,
	paths	: {
		Bleext	: &#34;js&#47;Bleext&#34;,
		CRM	: &#34;js&#47;Crm&#34;
	}
});
</pre>
<h3>Load classes dynamically</h3>
<p>First of all let&#8217;s <a href="http://www.bleext.com/blog/creating-classes/">create the class</a> so we can load it later, if you remember, one of <a href="http://www.bleext.com/blog/naming-conventions/">the conventions</a> is that the name of the file must be the same as the class, also the file must be located according to the namespace assigned. Let&#8217;s create a file in the &#8220;js/Bleext/training/UsuarioPanel.js&#8221; and then define the class as follows:</p>
<pre name="code" class="prettyprint">
Ext.define(&#34;Bleext.training.UsuarioPanel&#34;,{
	extend		: &#34;Ext.panel.Panel&#34;,
	
	title		: &#34;User&#34;,
	width		: 300,
	height		: 250,

	initComponent	: function() {
		var me = this;
		
        	me.html = &#34;This is Jhon Doe!&#34;;

		me.callParent();
	}
});
</pre>
<p>The previous class <a href="http://www.bleext.com/blog/single-inheritance/">extends from the panel</a> class and adds a title, size and content, it doesn&#8217;t have any important functionality but it&#8217;s enough for this example.</p>
<p>The next thing is to load the class and instantiate it as follows:</p>
<pre name="code" class="prettyprint">
&#47;&#47;...

&#47;&#47;Loading the class
Ext.require(&#34;Bleext.training.UsuarioPanel&#34;);

Ext.onReady(function(){
	var john = Ext.create(&#34;Bleext.training.UsuarioPanel&#34;,{
		renderTo	: Ext.getBody()
	});
	
	john.center();
});
</pre>
<p>This code goes in the app.js file we created at the beginning, we&#8217;ve already configured the Loader with the paths there.</p>
<p>Finally, it is necessary to create the HTML which includes the Ext4 library and the file app.js.</p>
<pre name="code" class="prettyprint">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta charset=&quot;UTF-8&quot; &#47;&gt;
	&lt;title&gt;ExtJS Loader&lt;&#47;title&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;..&#47;common&#47;js&#47;Ext&#47;resources&#47;css&#47;ext-all.css&quot; type=&quot;text&#47;css&quot; media=&quot;screen&quot; title=&quot;no title&quot; charset=&quot;utf-8&quot;&gt;
	&lt;script src=&quot;..&#47;common&#47;js&#47;Ext&#47;ext-all-dev.js&quot; type=&quot;text&#47;javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;&#47;script&gt;
	
	&lt;script src=&quot;js&#47;app.js&quot; type=&quot;text&#47;javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;&#47;script&gt;
&lt;&#47;head&gt;
&lt;body&gt;
	
&lt;&#47;body&gt;
&lt;&#47;html&gt;
</pre>
<p>When you run the example in the browser you will see a nice panel in the center of the screen, as shown in the following image:</p>
<p><!-- imagen 1 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/10/loader-01.png" alt="Loading dynamic class i ExtJS" /></p>
<p>Using the Loader</p>
</div>
<h3>Load only the necessary classes of Ext</h3>
<p>So far we have uploaded the entire library of Ext JS, but sometimes we don&#8217;t use all components of the library and it may not be worth it to load it, for those cases we can load only those components we need, to do that we need to use the file &#8220;ext-dev.js&#8221; instead of &#8220;ext-all-dv.js&#8221;</p>
<pre name="code" class="prettyprint">
&lt;!-- Delete this line --&gt;
&lt;script src=&quot;..&#47;common&#47;js&#47;Ext&#47;ext-all-dev.js&quot; type=&quot;text&#47;javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;&#47;script&gt;

&lt;!-- add this line in the HTML --&gt;
&lt;script src=&quot;..&#47;common&#47;js&#47;Ext&#47;ext-dev.js&quot; type=&quot;text&#47;javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;&#47;script&gt;
</pre>
<p>The file ext-dev.js only contains the classes needed to load classes on demand, also it contains some other utilities.</p>
<p>If we update the example on the browser at this moment we will see an error telling us that the class couldn&#8217;t be loaded: “Failed loading &#8216;src/panel/Panel.js&#8217;, please verify that the file exists”.</p>
<p><!-- imagen 2 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/10/loader-02.png" style="width:590px" alt="Failed loading 'src/panel/Panel.js', please verify that the file exists" /></p>
<p>We need to set the correct path</p>
</div>
<p>This happens because we need to specify the path where the library is found, in this case I have it located in a folder called &#8220;common/js/Ext&#8221;, in that folder there&#8217;s another folder called &#8220;src&#8221; where all the classes are separated by file, this is the location where we should set the path so the files can be loaded, let&#8217;s modify the &#8220;app.js&#8221; file and add the new path as follows:</p>
<pre name="code" class="prettyprint">
Ext.Loader.setConfig({
	enabled	: true,
	paths	: {
		Ext	: &#34;..&#47;common&#47;js&#47;Ext&#47;src&#34;,
		Bleext	: &#34;js&#47;Bleext&#34;,
		CRM	: &#34;js&#47;Crm&#34;
	}
});
</pre>
<p>Now we can see the the panel in our screen and if we open the console we&#8217;ll see all the files that have been loaded dynamically.</p>
<p><!-- imagen 3 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/10/loader-03.png" alt="Loading dynamic class i ExtJS" style="width:590px" /></p>
<p>Loading too many classes</p>
</div>
<p>You probably noticed that the panel was rendered slower than when we loaded the classes dynamically, this is because more files are being downloaded, the best thing to do is to create a custom version of Ext with only the classes that we&#8217;ll use and compressed it into a single file to avoid downloading all the separate classes. Later on I will show how to create a customized Ext version because it requires a separate tutorial.</p>
<h3>Conclusion</h3>
<p>In this tutorial we saw how to configure the loader and load classes dynamically, also we saw how to load the classes from the Ext library. When our application is deployed in production it is recommended to generate a single compressed file with the version of Ext, also the packages should be compressed too and contain all the classes of the modules of our application. In future tutorials I will talk more about the Loader since there are other things to talk about.</p>
<p>Remember to <a href="http://twitter.com/bleext">follow us on twitter</a> or subscribe to <a href="http://eepurl.com/gzXJz">our mailing list</a> in order to receive updates for coming tutorials about Ext JS.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/Fc5aV-bi5-M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/loading-classes-dynamically-with-extjs4/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/loading-classes-dynamically-with-extjs4/</feedburner:origLink></item>
		<item>
		<title>Naming conventions</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/PiY02hrm4Gc/</link>
		<comments>http://www.bleext.com/blog/naming-conventions/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 09:17:25 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=138</guid>
		<description><![CDATA[Ext JS 4 introduces a file upload system on demand, something that was sorely missing in previous versions, if...]]></description>
			<content:encoded><![CDATA[<p>Ext JS 4 introduces a file upload system on demand, something that was sorely missing in previous versions, if you need to use this new class loading system there are certain rules and conventions that we need to follow in order to make our lives easier.<br />
<span id="more-138"></span><br />
Here are the conventions to consider when defining a class if we want to use the Ext Loader class to load our classes dynamically.</p>
<h3>Classes and files with the same name</h3>
<p>When trying to load a class we do it by its name, which is why it is very important that both, the name of the class and the name of the file are identical. That is, if we create a class called &#8220;User&#8221; we must create a file called &#8220;User.js&#8221; that will contain the code.</p>
<pre name="code" class="prettyprint">
&#47;&#47; User.js
Ext.define(&#34;User&#34;,{
    name  : &#34;John&#34;
});
</pre>
<h3>Using &#8220;Camel case&#8221; for class names</h3>
<p>We recommend using &#8220;camel case&#8221; to define the class name, this will allow us to easily differentiate between a class and a package, for example User, Role, UserRole.</p>
<pre name="code" class="prettyprint">

Ext.define(&#34;UserView&#34;,{
    name  : &#34;John&#34;,
    &#47;&#47; ...
});

Ext.define(&#34;UserGrid&#34;,{
    name  : &#34;John&#34;,
    &#47;&#47; ...
});
</pre>
<h3>Namespaces in lowercase</h3>
<p>The packages should be name in lowercase to easily differentiate between classes and packages:</p>
<pre name="code" class="prettyprint">

Ext.define(&#34;Bleext.users.controller.UserController&#34;,{
    &#47;&#47; ...
});

Ext.define(&#34;CRM.security.groups.view.GroupsGrid&#34;,{
    &#47;&#47; ...
});

</pre>
<h3>Packages as folders</h3>
<p>Usually when we create a class we define it in a &#8220;namespace&#8221; (if you still do not: do it!), it is recommended that for every &#8220;dot&#8221; there must be a physical folder, for example, if we have a class called &#8220;Bleext.users.controller.UserController&#8221; there should be a file in the path &#8220;Bleext/users/controller/UserController.js&#8221;, this is very important so the Loader can work properly.</p>
<pre name="code" class="prettyprint">
&#47;&#47; Bleext&#47;users&#47;controller&#47;UserController.js
Ext.define(&#34;Bleext.users.controller.UserController&#34;,{
    &#47;&#47; ...
});

&#47;&#47; CRM&#47;security&#47;groups&#47;view&#47;GroupsGrid.js
Ext.define(&#34;CRM.security.groups.view.GroupsGrid&#34;,{
    &#47;&#47; ...
});

</pre>
<h3>Avoid using numbers in the names</h3>
<p>Avoid the use of numbers in package names or class names like Users4Roles, Class2 and similar names should be avoided. Let&#8217;s try to assign meaningful names and properly packaged. Avoid using acronyms in class is also recommended.</p>
<p>But there&#8217;s always an exception to the rule, since there are algorithms such as MD5 or SH4 we can use for a class name and the some acronyms like HTTP can be used if necessary.</p>
<h3>Avoid using underscores</h3>
<p>Avoid using the underscore (_) to separate words in the name of a class or package; User_Role, User_Grid are examples of names that we should avoid using.</p>
<pre name="code" class="prettyprint">

&#47;&#47;evitar esto
Ext.define(&#34;Bleext.users.controller.User_Controller&#34;,{
    &#47;&#47; ...
});

</pre>
<p>These are only conventions, nobody is obliged to follow them but if we use them we can use the Loader in a very simple, in the following tutorial I will talk about it more.</p>
<p>We&#8217;re planning to write more tutorials about Ext JS, <a href="http://twitter.com/bleext">follow us on twitter</a>, subscribe to <a href="http://eepurl.com/gzXJz">our mailing list</a> or <a href="http://feeds.feedburner.com/Bleext">our feeds</a> if you want to receive our updates.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/PiY02hrm4Gc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/naming-conventions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/naming-conventions/</feedburner:origLink></item>
		<item>
		<title>Configurations, Statics and Singleton in Ext JS 4</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/AbQKlS-P0Z4/</link>
		<comments>http://www.bleext.com/blog/configurations-statics-and-singleton-in-ext-js-4/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 08:29:21 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=136</guid>
		<description><![CDATA[As I mentioned in previous tutorials, Ext4 adds new functionality to the classes in a very simple way using...]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in previous tutorials, Ext4 adds new functionality to the classes in a very simple way using the pro/pre-processors, this tutorial will explain how to use configurations, create static properties and define a class as Singleton.<br />
<span id="more-136"></span></p>
<h3>Using configurations</h3>
<p>It is common that when we create classes we define the settings for them, usually these settings will serve to modify the behavior of the class or possibly to modify the visual appearance of the component.</p>
<p>In previous versions, we used to define the configurations as properties of the class, these were overwritten when an instance was created. In ExtJS 4 there&#8217;s a new property called &#8220;config&#8221;, which is an object that is designed to contain all the configurations that are needed in a class.</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.desktop.User&#34;,{
	config	: {
		name	: &#34;John&#34;,
		lastname: &#34;Doe&#34;
	},
	
	constructor	: function(options){
		this.initConfig(options);
	}
});
</pre>
<p>Within the object &#8220;config&#8221; we can add any number of properties that will be used as configurations, this allows us to keep the settings grouped improving the organization of our code.</p>
<p>Another important aspect is that in the constructor the configurations are being initialized, with the parameter &#8220;options&#8221; we can initialize the configurations for each instance we create.</p>
<pre name="code" class="prettyprint">
var john = Ext.create(&#34;Bleext.desktop.User&#34;,{
	name	: &#34;Susan&#34;
});

console.log(john.getName());

john.setName(&#34;Mary&#34;);

console.log(john.getName());
</pre>
<p>In the previous code we created an instance of the class &#8220;User&#8221; and overwritten the configuration &#8220;name&#8221; assigning it &#8220;Susan&#8221;, later we can make use of getters and setters that are automatically created for each configuration, for example &#8220;getName&#8221; and &#8220;setName&#8221;.</p>
<h3>Defining static methods and properties</h3>
<p>To define a static property we only need to use the property &#8220;statics&#8221; and assign it an object with all methods and properties that will belong to the class and not the instance.</p>
<pre name="code" class="prettyprint">
Ext.define(&#34;Bleext.desktop.User&#34;,{
	config	: {
		name	: &#34;John&#34;,
		lastname: &#34;Doe&#34;
	},
&#47;&#47;Properties that will be added to the class and not the instances
	statics		: {
		VISITOR		: 1,
		USER		: 2,
		ADMINISTRATOR	: 3
	},
	
	constructor	: function(options){
		this.initConfig(options);
	}
});
</pre>
<p>In the previous example qw defined three properties, these properties will only exist in the class and is not necessary to create instances to invoke them.</p>
<pre name="code" class="prettyprint">
console.log(Bleext.desktop.User.VISITOR);
console.log(Bleext.desktop.User.USER);
console.log(Bleext.desktop.User.ADMINISTRATOR);
</pre>
<h3>Singleton</h3>
<p>By definition a &#8220;singleton&#8221; class is the kind of class where you cannot have more than one instance of it, in Ext JS 4 to define a class of this kind we only have to add the property &#8220;singleton&#8221; equal to true.</p>
<pre name="code" class="prettyprint">
Ext.define(&#34;Bleext.desktop.Constants&#34;,{
	singleton	: true,
	
	LOGIN_URL	: &#34;&#47;login.do&#34;,
	LOGOUT_URL	: &#34;&#47;logout.do&#34;,
	
	GET_USERS_URL	:  &#34;&#47;users&#47;all&#34;,
	GET_USER_URL	: &#34;&#47;users&#47;get&#34;
});

console.log(Bleext.desktop.Constants.GET_USERS_URL);
</pre>
<p>The previous class instance doesn&#8217;t need to instantiated, because we have access to the members directly. If for some reason we wanted to create an instance of this class we would receive an error when trying.</p>
<pre name="code" class="prettyprint">
&#47;&#47;&#39;Bleext.desktop.Constants&#39; is a singleton and cannot be instantiated
Ext.create(&#34;Bleext.desktop.Constants&#34;);
</pre>
<p>This happens because the singleton class can not be instantiated by definition.</p>
<h3>Conclusion</h3>
<p>This tutorial briefly describes three new features in the class system that Ext4 introduces, we can see that certain tasks are much clearer than in previous versions (such as singleton classes or configurations). Normally the singleton class is used to handle the &#8220;Constants&#8221; of an application or any other circumstance which requires a single instance of a class.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/AbQKlS-P0Z4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/configurations-statics-and-singleton-in-ext-js-4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/configurations-statics-and-singleton-in-ext-js-4/</feedburner:origLink></item>
		<item>
		<title>Using alias and xtype in Extjs4</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/ZKl-NzsEIrE/</link>
		<comments>http://www.bleext.com/blog/using-alias-and-xtype-in-extjs4/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 13:10:53 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=134</guid>
		<description><![CDATA[The Ext JS version 4 provides several interesting options, the way in which the xtype of the components is...]]></description>
			<content:encoded><![CDATA[<p>The Ext JS version 4 provides several interesting options, the way in which the xtype of the components is defined has changed and it has new special properties now. In this tutorial I will show you the new features.<br />
<span id="more-134"></span></p>
<h3>Defining el xtype</h3>
<p>If you&#8217;ve worked with ExtJS version 3 you already know what is the xtype, but in short the xtype is an alias to define components in a literal way, for example:</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.Teacher&#34;,{
	extend 	: &#34;Ext.panel.Panel&#34;,
	alias		: &#34;widget.teacher&#34;

	&#47;&#47; ...
});
</pre>
<p>In the previous class we used the property &#8220;alias&#8221; to define the xtype of the class, as opposed to Ext3 in this version we have to assign a prefix. The prefix ​​&#8221;widget&#8221; is used in the case of any class that inherits directly or indirectly from &#8220;Ext.Component&#8221;, there are several prefixes for the different components that exist within the framework.</p>
<h3>Prefixes in the xtype</h3>
<p>To identify which prefixes are available we can run the following code:</p>
<pre class="prettyprint">
var prefix = {},
	values = &#91;&#93;;
	
Ext.Object.each(Ext.ClassManager.maps.aliasToName,function(key,value){
	var px = key.split(&#34;.&#34;)&#91;0&#93;;

	if(!prefix&#91;px&#93;){
		prefix&#91;px&#93; = px;
		values.push(px);
	}
});
console.log(values);
</pre>
<p>The class &#8220;ClassManager&#8221; is responsible for creating the classes, that&#8217;s the reason why the &#8220;alias&#8221; of all the classes that exist in the framework are defined here. The result of the previous code is the following:</p>
<pre class="prettyprint">
&#91;layout,writer,data,reader,proxy,widget,axis,store,series,association,direct,state,formaction,feature,editing,plugin,selection&#93;
</pre>
<p>Basically the prefix is used to group classes, in this way we can have a xtype &#8220;store.teacher&#8221; and other &#8220;widget.teacher&#8221;, the difference is the prefix.</p>
<h3>Creating the class using its xtype</h3>
<p>Having defined the class and assigned the alias with its own prefix, we can instantiate the class using the xtype as follows:</p>
<pre class="prettyprint">
Ext.onReady(function(){
var p = Ext.create(&#34;Ext.panel.Panel&#34;,{
	width	: 300,
	height	: 400,
	items	: &#91;{
		xtype	: &#34;teacher&#34;,	&#47;&#47;Using the xtype
		title 	: &#34;John Doe&#34;,
		html	: &#34;I&#39;m a teacher!&#34;
	}&#93;,
	renderTo	: Ext.getBody()
});
p.center();
});
</pre>
<p><!-- imagen 1 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/09/xtype-01.jpg" />
</div>
<p>It is important to notice that when instantiating the class &#8220;Teacher&#8221; we are not using the prefix, this is because it inherits from &#8220;Ext.Component&#8221; (indirectly) and all components use the prefix &#8220;widget&#8221; therefore is not necessary to use the prefix.</p>
<p>We may also use the method &#8220;widget&#8221; as follows:</p>
<pre name="code" class="prettyprint">
var susan = Ext.widget(&#34;teacher&#34;,{
	title 	: &#34;Susan Smith&#34;,
	html	: &#34;I&#39;m a teacher&#34;
});
var p = Ext.create(&#34;Ext.panel.Panel&#34;,{
	width	: 300,
	height	: 400,
	items	: &#91;{
		xtype	: &#34;teacher&#34;,	&#47;&#47;Using the xtype
		title 	: &#34;John Doe&#34;,
		html	: &#34;I&#39;m a teacher!&#34;
	},
		susan  &#47;&#47;adding the instance susan to the container that we already had
	&#93;,
	renderTo	: Ext.getBody()
});
</pre>
<p><!-- imagen 2 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/09/xtype-02.jpg" />
</div>
<h3>Conclusion</h3>
<p>When defining an alias to the class we are creating we can easily instantiate it later under that alias, this prevents us from writing a few extra lines of code and it helps us define the components faster.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/ZKl-NzsEIrE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/using-alias-and-xtype-in-extjs4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/using-alias-and-xtype-in-extjs4/</feedburner:origLink></item>
		<item>
		<title>Multiple inheritance in Ext 4 (mixins)</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/3zxt87PC4GA/</link>
		<comments>http://www.bleext.com/blog/multiple-inheritance-in-ext-4-mixins/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 06:56:43 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=93</guid>
		<description><![CDATA[This new version (Ext4) has been written completely new, with the purpose of making it very flexible and easy...]]></description>
			<content:encoded><![CDATA[<p>This new version (Ext4) has been written completely new, with the purpose of making it very flexible and easy to learn, one of the new features that this version provides is that now we can do multiple inheritance using mixins. In this tutorial we will see how to use mixins and use them correctly.<br />
<span id="more-93"></span><br />
To set multiple inheritance to a class we simply have to add the property &#8220;mixins&#8221;, this property must be an object with all the classes we want to inherit from or want to mix.</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.Icon&#34;,{
	mixins	: {
		floating		: &#34;Ext.util.Floating&#34;,
		observable	: &#34;Ext.util.Observable&#34;
	}
	&#47;&#47;......
});
</pre>
<p>In the previous example we created a class called &#8220;Icon&#8221;, this class inherits directly from &#8220;Ext.Base&#8221; because we didn&#8217;t explicitly inherit from another class, by using the property &#8220;mixins&#8221; we are saying that the class &#8220;Icon&#8221; will inherit from two classes: &#8221; floating &#8220;and&#8221; observable &#8220;.</p>
<p>The Floating class contains the methods necessary to position an element in the coordinates &#8220;X&#8221; and &#8220;Y&#8221; that we indicate to the instance, while the class &#8220;Observable&#8221; allows us to handle events within the class &#8220;Icon&#8221;.</p>
<p>If at this time we create an instance of &#8220;Icon&#8221; we will have all the properties and methods of the class &#8220;Ext.Base&#8221;, &#8220;Floating&#8221; and &#8220;Observable&#8221;.</p>
<h3>Overriding the constructor</h3>
<p>So far we have not defined a constructor for the class we&#8217;ve created, so the question is, what constructor of the three classes we are &#8220;inheriting&#8221; will be executed when the instance is being built?</p>
<p>To answer the previous question we must understand that the &#8220;pre-processor&#8221; (In a future post I will explain about the pre/post-processors) of mixins copies the methods and properties IF that method or property DOES NOT EXIST in the target class.</p>
<p>According to the mentioned previously the class &#8220;Icon&#8221; inherits the constructor of the class &#8220;Base&#8221; by single inheritance, this means that the constructors of &#8220;Floating&#8221; and &#8220;Observable&#8221; are not being executed and probably these constructors have important actions. So what we need to do is run the constructors of the mixins manually.</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.Icon&#34;,{
	mixins	: {
		floating	: &#34;Ext.util.Floating&#34;,
		observable	: &#34;Ext.util.Observable&#34;
	},
	
	width	: 100,
	height	: 100,
	border	: true,
	
	constructor	: function(options){
		Ext.apply(this,options);
		
		this.id = Ext.id(null,&#34;icon-&#34;);	&#47;&#47;Assigning a dynamic identifier

		this.addEvents(&#34;moved&#34;,&#34;created&#34;);	&#47;&#47;method inherited from the class Observable
		
		if(this.renderTo){
			this.render(this.renderTo);
			delete this.renderTo;
		}
		
		this.mixins.floating.constructor.call(this);	&#47;&#47;executing manually the
		this.mixins.observable.constructor.call(this); &#47;&#47;constructors of the mixins
	}
});
</pre>
<p>To access the instances of the mixins we must use the property &#8220;this.mixins&#8221; followed by the name we assigned when we configured it.</p>
<p>This same concept is applied when there are methods with the same name in different classes that are inherited.</p>
<h3>Rendering the Icon class</h3>
<p>In the previous code the method &#8220;render&#8221; was executed if the property &#8220;renderTo&#8221; has been defined in the configuration parameters, it is our duty to implement this method.</p>
<pre class="prettyprint">
render		: function(where){
	if(where){
		this.container = Ext.get(where);			&#47;&#47; 1
		this.el = Ext.core.DomHelper.append(where,{	&#47;&#47; 2
			id	: this.id,
			tag	: &#34;div&#34;
		});
		this.el = Ext.get(this.el);
		this.el.setStyle({					&#47;&#47; 3
			width	: this.width?this.width+&#34;px&#34;:&#34;auto&#34;,
			height	: this.height?this.height+&#34;px&#34;:&#34;auto&#34;,
			border	: this.border?&#34;1px solid #aaa&#34;:&#34;none&#34;,
			background	: &#34;#eee&#34;
		});
	}
},
	
setPagePosition	: function(xy){		&#47;&#47; 4
	this.el.setLeftTop(xy&#91;0&#93;+&#34;px&#34;,xy&#91;1&#93;+&#34;px&#34;);
	this.fireEvent(&#34;moved&#34;,xy);
}
</pre>
<p>In step 1, the reference of the container element is taken using the &#8220;Ext.get&#8221; method which returns an instance of the object &#8220;Ext.Element&#8221; which contains the reference to the DOM and also several methods to manipulate it in a simple manner.</p>
<p>In step 2 the element that will represent the class &#8220;Icon&#8221; is created, using the class &#8220;Ext.DomHelper&#8221; we can create DOM ​​elements in a very simple way, in this case we used the method &#8220;append&#8221; to add a node to the container .</p>
<p>In step 3 we apply the styles such as width, height, etc&#8230; These styles can be sent using the configuration object to change the default values.</p>
<p>In step 4 we define a function to assign the position of the element that represents the class &#8220;Icon&#8221;, this method is required to use the method &#8220;center&#8221; that we inherited from the class &#8220;Floating&#8221;.</p>
<h3>Instantiating the class Icon</h3>
<p>We have created a class that uses mixins, now we are going to test it by using an instance of it and executing some of the inherited methods.</p>
<pre class="prettyprint">
Ext.onReady(function(){
	var icon = Ext.create(&#34;Bleext.training.Icon&#34;,{
		renderTo	: Ext.getBody()
	});

	icon.on(&#34;moved&#34;,function(xy){	&#47;&#47;inherited from Observable
		console.log(xy);
	});
	
	icon.center();			&#47;&#47;inherited from Floating
});
</pre>
<p>When you execute the example you will see a square in the center of the screen, we didn&#8217;t programmed the functionality of centering the square because we inherited that functionality from the class &#8220;Floating&#8221; which is responsible for calculating the center.</p>
<p>We also used the method &#8220;on&#8221; that has been inherited from class &#8220;Observable&#8221; and it&#8217;s used to add events to classes.</p>
<h3>Difference between a mixin and plugin</h3>
<p>Through mixins we can add properties and methods to a class, but if you think about it plugins do the same thing right? Yes, they do something very similar, they add extra functionality to a class.</p>
<p>The main difference is that a mixin is added at the class level and a plugin is added at the instance level, this means that the mixins are part of the definition of the class, while the plugins are not.</p>
<h3>Conclusion</h3>
<p>The mixins are useful to mix or add functionality from other classes to the class that we are defining, it help us to design a more robust and flexible application.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/3zxt87PC4GA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/multiple-inheritance-in-ext-4-mixins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/multiple-inheritance-in-ext-4-mixins/</feedburner:origLink></item>
		<item>
		<title>Single Inheritance</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/fFJNHpyRKzA/</link>
		<comments>http://www.bleext.com/blog/single-inheritance/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 13:27:37 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=90</guid>
		<description><![CDATA[Ext JS has always been characterized as an object oriented library, from the first version Ext JS has provided...]]></description>
			<content:encoded><![CDATA[<p>Ext JS has always been characterized as an object oriented library, from the first version Ext JS has provided a system for creating classes and inheritance, among releases it has been changing a bit, but in version 4 the system classes have changed considerably.<br />
<span id="more-90"></span><br />
We saw <a href="http://www.bleext.com/blog/creating-classes/">how to create classes</a> with the new system, now we will learn how to extend a class and add extra functionality. </p>
<h3>Extending</h3>
<p>To extend a class we must define the property &#8220;extend&#8221; followed by the class from which we want to inherit.</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.UserPanel&#34;,{
	extend 	: &#34;Ext.panel.Panel&#34;,	&#47;&#47;&lt;-- Inheritance

	title 		: &#34;User information&#34;,
	width		: 300,
	height		: 300,
	bodyPadding	: 10,
	html		: &#34;Testing!&#34;	
});
</pre>
<p>By using the &#8220;Ext.define&#8221; method we are defining a class that inherits from &#8220;Ext.panel.Panel&#8221;, when we do this automatically our class has all the methods and properties of the panel, apart from this we can configure or specialize our class. In this case we have only added a few configurations, the following thing we need to do is to create an instance of that class and render it somewhere in our document.</p>
<pre class="prettyprint">
Ext.onReady(function(){
	Ext.create(&#34;Bleext.training.UserPanel&#34;,{
		renderTo	: &#34;center&#34;	&#47;&#47;&lt;-- the DIV in where we defined the html
	});
});
</pre>
<p><!-- imagen 1 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/09/herencia-01.jpg" alt="Inheriting from Ext.panel.Panel" />
<p>Inheriting from Ext.panel.Panel</p>
</div>
<p>The method "Ext.onReady" (as in version 3) executes the anonymous function as a parameter when the DOM is ready, therefor inside of that function we create an instance of the class we've just defined.</p>
<h3>Using a template</h3>
<p>In Ext4 there's a property called "tpl" which lets you add an instance of the class Ext.XTemplate or an array with the parameters that will be received by the XTemplate class so it be created automatically, also we can define a property "data" with the information the template will use.</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.UserPanel&#34;,{
	extend 	: &#34;Ext.panel.Panel&#34;,	&#47;&#47;&lt;-- Inheritance

	title 		: &#34;User information&#34;,
	width		: 300,
	height		: 300,
	bodyPadding	: 10,
	html		: &#34;Testing!&#34;

	data		: {
		name	: &#34;John&#34;,
		lastname: &#34;Doe&#34;,
		company	: &#34;Bleext&#34;,
		age	: 27,
		status	: &#34;Active&#34;,
		phone	: &#34;(12) 34 567 890&#34;
	},
	tpl		: &#91;
		&#39;&lt;p&gt;&lt;strong&gt;Name&lt;&#47;strong&gt;: {name} {lastname}&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Company&lt;&#47;strong&gt;: {company}&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Age&lt;&#47;strong&gt;: {age} years old&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Phone&lt;&#47;strong&gt;: {phone}&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Status&lt;&#47;strong&gt;: {status}&lt;&#47;p&gt;&#39;
	&#93;	
});
</pre>
<p><!-- imagen 2 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/09/herencia-02.jpg" alt="Using a template for the content" />
<p>Using a template for the content</p>
</div>
<p>Notice how in the templates we defined the fields of the object "data" between braces "{" and "}", this will replace the values ​​dynamically in the generated HTML.</p>
<h3>Overriding methods</h3>
<p>It is very common when develop in an object-oriented way to add extra functionality on the methods or specialized them in some specific task of the class we are defining.</p>
<p>When overwriting a method we should consider that we are eliminating the functionality that was inherited, therefore we must call the super class method to lose nothing. Ext JS 4 provides a simple way to execute a method that has been over-written, we just have to run the method "callParent" and the library automatically identifies the correct method.</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.UserPanel&#34;,{
	extend 	: &#34;Ext.panel.Panel&#34;,	&#47;&#47;&lt;-- Inheritance

	title 		: &#34;User information&#34;,
	width		: 300,
	height		: 300,
	bodyPadding	: 10,

	data		: {
		name	: &#34;John&#34;,
		lastname: &#34;Doe&#34;,
		company	: &#34;Bleext&#34;,
		age	: 27,
		status	: &#34;Active&#34;,
		phone	: &#34;(12) 34 567 890&#34;
	},
	tpl		: &#91;
		&#39;&lt;p&gt;&lt;strong&gt;Name&lt;&#47;strong&gt;: {name} {lastname}&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Company&lt;&#47;strong&gt;: {company}&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Age&lt;&#47;strong&gt;: {age} years old&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Phone&lt;&#47;strong&gt;: {phone}&lt;&#47;p&gt;&#39;,
		&#39;&lt;p&gt;&lt;strong&gt;Status&lt;&#47;strong&gt;: {status}&lt;&#47;p&gt;&#39;
	&#93;,

	initComponent	: function(){
		var me = this;
		
		me.tbar = &#91;{text:&#34;Save&#34;},{text:&#34;Edit&#34;},{text:&#34;Delete&#34;}&#93;;

		me.callParent();	&#47;&#47;&lt;-- super class call
	}
});
</pre>
<p><!-- imagen 3 --></p>
<div class="example">
<img src="http://www.quizzpot.com/wp-content/uploads/2011/09/herencia-03.jpg" alt="Overriding the method initComponent" />
<p>Overriding the method initComponent</p>
</div>
<p>In the previous example we are overwriting the method "initComponent" to add a toolbar at the top part of the panel, notice how in the last line the "initComponent" of the super class is called, this is very important because if we don't do it the component will not work, this is because in the super class the "initComponent" makes several important things.</p>
<p>In Ext3 there was a property called "superclass" that was added as static to the classes, this has disappeared and instead we have to use the method "callParent" which is smart enough to know which method needs to be called in the super class.</p>
<h3>Conclusion</h3>
<p>ExtJS was created to be inherited, as we develop our own application we will use single inheritance to extend the components that the library has. In today's example we created an user form extending from the panel class, we can extend from any other class of the framework and specialize it through simple inheritance.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/fFJNHpyRKzA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/single-inheritance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/single-inheritance/</feedburner:origLink></item>
		<item>
		<title>Creating Classes in ExtJS 4</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/by3EX1YDhQ0/</link>
		<comments>http://www.bleext.com/blog/creating-classes/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 13:47:18 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=87</guid>
		<description><![CDATA[Ext4 defines a new way of creating classes, I think it is much simpler and clearer to understand the...]]></description>
			<content:encoded><![CDATA[<p>Ext4 defines a new way of creating classes, I think it is much simpler and clearer to understand the way it works now, also with the new pre-processors and post-processors we have many possibilities to create our classes.<br />
<span id="more-87"></span></p>
<p>In this tutorial I&#8217;m going to show you how to create simple classes, ExtJS 4 introduce a great way to deal with classes.</p>
<h3>Class definition</h3>
<p>To create a simple class we only have to use the method &#8220;Ext.define&#8221; or &#8220;Ext.ClassManager.create&#8221; as follows:</p>
<pre class="prettyprint">
Ext.define(Name,Configurations,Callback);
Ext.ClassManager.create(Name,Configurations,Callback);
</pre>
<p>The first parameter defines the name of the class and it must be a String.<br />
The second parameter defines the members of the class and it should an object with all the properties and methods we need in the new class.<br />
The third parameter defines a function (optional) that its executed when the class is created, this is useful when creating classes that have to be included asynchronously using the Loader.</p>
<p>Here is an example of a class called User:</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.User&#34;,{
username	: &#34;&#34;,
password	: &#34;&#34;,

login		: function(){
	console.log(&#34;Loging in....&#34;);
},

logout		: function(){
	console.log(&#34;Loging out....&#34;);
}
});
</pre>
<p>We have created a class called &#8220;User&#8221; in the namespace &#8220;Bleext.training&#8221;. Unlike Ext3, now we will define the name and the namespace in the first parameter and is no longer necessary to use the traditional Ext.ns that we used in version 3.<br />
The second parameter is an object with two properties and two methods, in here we can define whatever we need.</p>
<h3>Overriding the constructor</h3>
<p>In the previous example we didn&#8217;t define a class constructor, therefore Ext assigned an empty constructor, if we wanted to define one we would have to use the property &#8220;builder&#8221; as follows:</p>
<pre class="prettyprint">
Ext.define(&#34;Bleext.training.User&#34;,{
username	: &#34;&#34;,
password	: &#34;&#34;,

constructor	: function(options){
	Ext.apply(this,options || {});

	console.log(&#34;A new user!&#34;);
}

login		: function(){
	console.log(&#34;Loging in....&#34;);
},

logout		: function(){
	console.log(&#34;Loging out....&#34;);
}
});
</pre>
<p>The property &#8220;constructor&#8221; is a special configuration (as in Ext3) that allows us to define the function that will build the object we are defining, in this case when we call the method &#8220;Ext.apply&#8221; it copies the contents of the object &#8220;options&#8221; to the instance that will be created, this gives us the possibility that when we create the instance we can assign values to the properties that were defined.</p>
<h3>Instance creation</h3>
<p>Once we have defined the class we can generate objects from it, to do this is necessary to invoke the method &#8220;Ext.create&#8221; or the method &#8220;Ext.ClassManager.instantiate&#8221; as follows:</p>
<pre class="prettyprint">
Ext.create(Class,Options);
Ext.ClassManager.instantiate(Class,Options);
</pre>
<p>Both methods do exactly the same, the first parameter defines the class that we want to instantiate (String) and the second parameter is an object with the settings that will be applied to the instance, for example:</p>
<pre class="prettyprint">
var john = Ext.create(&#34;Bleext.training.User&#34;,{
	username	: &#34;john&#34;,
	password	: &#34;123&#34;
});

console.log(john);
</pre>
<p>When we print the object &#8220;john&#8221; in the console we will see how the original properties are overwritten with the settings that we assigned when we to created the instance.</p>
<h3>Conventions</h3>
<p>It&#8217;s not a rule, but it is a convention that when we name a class we should use the format &#8220;camel case&#8221;, for example:</p>
<pre class="prettyprint">
UserPanel, 
UserGrid, 
UserForm, 
UserStore
</pre>
<p>There is another convention that recommends writing in &#8220;camel case&#8221; the <em>root</em> object of our &#8220;namespace&#8221; and write in lowercase all the packages, so you can easily differentiate between classes and packages, for example:</p>
<pre class="prettyprint">
Bleext.modules.security.roles.controller.Roles
Bleext.modules.security.roles.model.Role
Bleext.modules.security.roles.store.Roles
Bleext.modules.security.roles.view.RolesGrid
Bleext.modules.security.roles.view.RolePanel
</pre>
<p>The previous examples show how we should define the name of our classes, as you can see it&#8217;s very easy to differentiate the &#8220;packages&#8221; from the classes.</p>
<h3>Performance Analysis</h3>
<p>If you noticed, the object Ext.ClassManager is responsible for the creation and management of classes within the framework, this object does several interesting things and it&#8217;s worth analyzing thoroughly to understand its operation.</p>
<p>When we create a class using &#8220;Ext.define&#8221; the method &#8220;Ext.ClassManager.create&#8221; is called and internally creates an instance of the class &#8220;Ext.Class&#8221;, this means that all the classes we define are instances of &#8220;Ext.Class&#8221;.</p>
<p>Ext.Class defines a process at the moment when the classes are instantiated, there are two major phases running in this process, &#8220;pre-processing&#8221; and &#8220;post-processing&#8221;, basically in these phases can add actions, by default there are several already defined, in the pre-processing phase we can find the following actions:</p>
<pre class="prettyprint">
extend,statics,inheritableStatics,mixins,config
</pre>
<p>These actions allows you to execute portions of code before the class is created sequentially, for example the action &#8220;extend&#8221; copies the prototypes of the superclass for the inheritance, the action &#8220;statics&#8221; statically defines the properties or methods that we defined in the new class and so on are executed the pre-processors in sequence.</p>
<p>Later in this blog we will see in detail each of these actions and how we can add them our own processes.</p>
<p>Another interesting point is that by default (if not define differently) the classes we create inherit from Ext.Base, this class defines the abstract functionality for all classes, we can find here methods such as &#8220;callParent&#8221;, &#8220;initConfig&#8221;. Later on we will discuss further details of this, but it is important to know that all classes inherit from &#8220;Ext.Base&#8221; either directly (if we didn&#8217;t define a super class) or indirectly (if it inherits from an existing class).</p>
<h3>Conclusion</h3>
<p>As we have seen, the class system is very flexible and complete, also the syntax for creating classes is quite understandable, on future posts we will talk about more features of using classes such as &#8220;mixins&#8221;, &#8220;configs&#8221;, &#8220;statics&#8221; and so on.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/by3EX1YDhQ0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/creating-classes/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/creating-classes/</feedburner:origLink></item>
		<item>
		<title>Installing Ext JS 4</title>
		<link>http://feedproxy.google.com/~r/Bleext/~3/EmsHDcmqRzE/</link>
		<comments>http://www.bleext.com/blog/installing-ext-js-4/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 20:42:19 +0000</pubDate>
		<dc:creator>Crysfel Villa</dc:creator>
		
		<guid isPermaLink="false">http://www.bleext.com/?post_type=bleext_blog&amp;p=84</guid>
		<description><![CDATA[As many of you have heard, Sencha (the company behind the development of ExtJS) has released the version 4...]]></description>
			<content:encoded><![CDATA[<p>As many of you have heard, Sencha (the company behind the development of ExtJS) has released the version 4 of the ExtJS framework a couple of months ago, if you&#8217;ve been working with previous versions you will notice many differences; in this tutorial I will show you how to install the version 4 of ExtJS .</p>
<p><span id="more-84"></span></p>
<p>&nbsp;</p>
<h3>Bidding farewell to the adapter</h3>
<p>For those who have been developing since the version 1 came out, we know that Ext JS was born as an extension of YUI, later on prototype, jQuery and base are introduced. To run the library with any of these four was necessary to import the adapter to serve as an &#8220;interpreter&#8221; between Ext and selected library (jQuery for example).</p>
<p>This has changed for the version 4, because is no longer necessary to import the adapter, in fact Ext is no longer an extension of any library and the developers of Sencha have decided to support only the Ext Core which is a library like jQuery or Prototype. This decision was taken so the Sencha Touch (which is the Mobile Library) could share code with ExtJS 4, besides several other advantages.</p>
<h3>Welcome Ext Dev</h3>
<p>When you download the version 4 you will find several files in the root directory, ext-all.js, ext-all-debug.js, ext-all-dev.js, ext.js, ext-dev.js</p>
<p>The file ext-all.js as in past versions contains all the library classes compressed and ready to go to the production environment.</p>
<p>In the ext-all-debug.js file the classes are uncompressed and is the file that we used in previous versions for the development environment.</p>
<p>In this version we find the ext-all-dev.js file, this file also contains the entire framework, but also contains error and warning messages that will be useful in the development phase, so from now on we should use it to develop.</p>
<p>We also find the files ext-dev.js and ext.js, these files are intended for when you do not need to load the entire library and just want to use a specific component, this means that these files only load the basic to be able to load dynamically only the classes that are required, we will discuss this later in detail.</p>
<h3>Installation example</h3>
<p>To install the library in a development environment is necessary to import the &#8220;ext-all-dev&#8221;, we also need to import the styles so the components can be displayed correctly. The HTML would be as follows:</p>
<pre class="prettyprint">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text&#47;html; charset=iso-8859-1&quot;&gt;
    &lt;title&gt;Ext.Panel&lt;&#47;title&gt;
    &lt;!-- Importing styles --&gt;
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text&#47;css&quot; href=&quot;..&#47;js&#47;Ext&#47;resources&#47;css&#47;ext-all.css&quot; &#47;&gt;

    &lt;!-- Importing the ext-all-dev.js --&gt;
    &lt;script type=&quot;text&#47;javascript&quot; src=&quot;..&#47;js&#47;Ext&#47;ext-all-dev.js&quot;&gt;&lt;&#47;script&gt;
    
    &lt;script type=&#34;text&#47;javascript&#34; &gt;
        Ext.onReady(function(){
            alert(&#34;Ext has been installed successfully!&#34;);
        });
    &lt;&#47;script&gt;
&lt;&#47;head&gt;
&lt;body&gt;
	&lt;div id=&quot;center&quot;&gt;&lt;&#47;div&gt;
&lt;&#47;body&gt;
&lt;&#47;html&gt;
</pre>
<p>Make sure to assign the routes of CSS and JS correctly, the folder structure in this example is as follows:</p>
<pre class="prettyprint">
+ course
   + classes
      - 01-installation.html
   + js
      + Ext
         - ext-all-dev.js
         + resources
            + css
               - ext-all.css
</pre>
<p>If you run the example in the browser and you get an error &#8220;Ext is undefined&#8221;, it&#8217;s very likely that the path to the file &#8220;ext-all-dev.js&#8221; is incorrect, be sure to write correctly.</p>
<p>If you run the example but you don&#8217;t get any error and still can&#8217;t see the components, is possible that the CSS path is incorrect, make sure it is spelled correctly and it is the correct path.</p>
<img src="http://feeds.feedburner.com/~r/Bleext/~4/EmsHDcmqRzE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bleext.com/blog/installing-ext-js-4/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.bleext.com/blog/installing-ext-js-4/</feedburner:origLink></item>
	</channel>
</rss>
