<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Saki's Blog</title>
	<atom:link href="http://blog.extjs.eu/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.extjs.eu</link>
	<description>For good of all productive developers</description>
	<lastBuildDate>Mon, 16 Aug 2010 23:12:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Factory Functions in Ext Extensions (Abstract Classes)</title>
		<link>http://blog.extjs.eu/know-how/factory-functions-in-ext-extensions/</link>
		<comments>http://blog.extjs.eu/know-how/factory-functions-in-ext-extensions/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 13:37:15 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Know-how]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=546</guid>
		<description><![CDATA[<br/>I have recently run across one of the the Jay Garcia&#8217;s excellent screencasts Abstract classes with Ext JS. (Thank you Jay for your effort of educating Ext JS community.)
I&#8217;ve been consulting in a company at that time &#8211; developers of the client, after seeing the screencast, immediately asked me: &#8220;So what should we use? The [...]]]></description>
			<content:encoded><![CDATA[<br/><p>I have recently run across one of the the <a href="http://tdg-i.com/">Jay Garcia&#8217;s</a> excellent screencasts <a href="http://tdg-i.com/364/abstract-classes-with-ext-js">Abstract classes with Ext JS</a>. (Thank you Jay for your effort of educating Ext JS community.)</p>
<p>I&#8217;ve been consulting in a company at that time &#8211; developers of the client, after seeing the screencast, immediately asked me: &#8220;So what should we use? The <a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/">&#8216;xtype&#8217; style</a> or Abstract classes?&#8221;</p>
<p>The curt answer would be: &#8220;Use whatever you prefer.&#8221; or &#8220;Use both&#8221;. </p>
<p>However, decisions based on mere &#8220;preference&#8221; or on &#8220;I use it because it is available&#8221; are often not fully rational and can lead to troubles as the application grows. Thus, let&#8217;s take a deeper look to see if there are any pitfalls and to find how can we get most of both methods. </p>
<p><b><i>Note:</i></b> Before you continue, read <a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/">&#8220;Writing a big application in Ext&#8221;</a>,  watch the J<a href="http://tdg-i.com/364/abstract-classes-with-ext-js">ay&#8217;s screencast</a> and understand both, otherwise, the following text won&#8217;t make any sense to you.</p>
<h1>Abstract ExtJS Class</h1>
<p>Abstract classes are not to be used directly but they serve more like templates that specify methods and properties to be implemented in classes derived from them. They are very useful in object oriented programming because they force developers to implement all mandatory methods with same signature (signature = arguments the method or function accepts) and return values so there is a greater chance to develop a bug free code.</p>
<p>However, in ExtJS (and JavaScript that is scripting language where source is not compiled but directly interpreted), there is no mechanism to warn developer &#8220;you haven&#8217;t implemented method XY&#8221; or &#8220;your implementation has wrong signature&#8221; so we need to take care ourselves.</p>
<p>Nevertheless, the idea of abstract classes is useful also in JavaScript/ExtJS environment because:</p>
<ol>
<li>
logic and configuration common to all expected descendants can be put in the abstract base class that eliminates the code duplication, speeds up development and debugging, and increases future code maintainability greatly
</li>
<li>
abstract classes tell us which methods to implement
</li>
<li>
it increases the human readability of the code (Remember, we always try to write the code to be readable and understandable by us and others in the future.)
</li>
</ol>
<h1>The Basic Idea</h1>
<p>The basic idea Jay presents in his great screencast is to extend an Ext Component, FormPanel for example, and add stub methods to it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">AbstractFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">FormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     submitUrl<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
             items<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">,</span>buttons<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildButtons</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        MyApp.<span style="color: #660066;">AbstractFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
&nbsp;
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
    <span style="color: #339933;">,</span>buildButtons<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildButtons</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span></pre></div></div>

<p>The empty &#8220;buildXxx&#8221; methods will be implemented in the abstract class extension.</p>
<h1>Tweaking the Abstract Class example</h1>
<p>While perfect for the educational purposes, we need to tweak this code if want to use it in the production quality application. I shall walk you through recommended improvements.</p>
<h2>initialConfig</h2>
<p>Ext.Component takes the config object passed to its constructor and saves it in the object variable <code>initialConfig</code> when it instantiates. Although items and buttons in combination with the FormPanel in the above example do not rely on it, so the example runs as expected, <code>initialConfig</code> is used on the Ext.Component level so it may be used by any of Component descendants. </p>
<p>Let&#8217;s take care of it and modify <code>initComponent</code> as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// create config object</span>
        <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// build config properties</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>config<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
             items<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">,</span>buttons<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildButtons</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// apply config</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initialConfig</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        MyApp.<span style="color: #660066;">AbstractFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span></pre></div></div>

<h2>Return Values</h2>
<p>Abstract methods in the example return empty arrays. That is no problem for items or buttons but if we want to have also <code>buildTbar</code> or <code>buildBbar</code> factory functions that return empty arrays [] then top and bottom toolbars are always created, but empty, if methods are not implemented in derived classes. (Empty toolbars are quite ugly when rendered.)</p>
<p>Therefore, always return undefined from the abstract methods. For now, the class could look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">AbstractFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">FormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     submitUrl<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// create config object</span>
        <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// build config properties</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>config<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
             items<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">,</span>buttons<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildButtons</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">,</span>tbar<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildTbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">,</span>bbar<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildBbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// apply config</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initialConfig</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        MyApp.<span style="color: #660066;">AbstractFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
&nbsp;
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
    <span style="color: #339933;">,</span>buildButtons<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildButtons</span>
&nbsp;
    <span style="color: #339933;">,</span>buildTbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildTbar</span>
&nbsp;
    <span style="color: #339933;">,</span>buildBbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildBbar</span></pre></div></div>

<h2>Passing <code>config</code> to Abstract Factory Methods</h2>
<p>If we pass <code>config</code> object to abstract methods then we can apply the created items, buttons, toolbar items directly to it. That has no great benefit in itself, however, if we create a sequence or interceptor of these methods we can use the config object directly.</p>
<p>So now we have:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">AbstractFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">FormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     submitUrl<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// create config object</span>
        <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// build config properties</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildItems</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildButtons</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildTbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildBbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// apply config</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initialConfig</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        MyApp.<span style="color: #660066;">AbstractFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
&nbsp;
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">items</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
    <span style="color: #339933;">,</span>buildButtons<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">buttons</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildButtons</span>
&nbsp;
    <span style="color: #339933;">,</span>buildTbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">tbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildTbar</span>
&nbsp;
    <span style="color: #339933;">,</span>buildBbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">bbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildBbar</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span></pre></div></div>

<h1>The Final Touch</h1>
<p>If you look in the <code>initComponent</code> now you see that we call a series of &#8220;build&#8221; functions in it. Let&#8217;s move it into another factory method:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">AbstractFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">FormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     submitUrl<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// create config object</span>
        <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// build config</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildConfig</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// apply config</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initialConfig</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        MyApp.<span style="color: #660066;">AbstractFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
&nbsp;
    <span style="color: #339933;">,</span>buildConfig<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildItems</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildButtons</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildTbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildBbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildConfig</span>
&nbsp;
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">items</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
    <span style="color: #339933;">,</span>buildButtons<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">buttons</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildButtons</span>
&nbsp;
    <span style="color: #339933;">,</span>buildTbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">tbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildTbar</span>
&nbsp;
    <span style="color: #339933;">,</span>buildBbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">bbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildBbar</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span></pre></div></div>

<p>The above gives you the flexibility of implementing or overriding of the whole <code>buildConfig</code> function or individual items, buttons, bars functions. It also takes care of <code>initialConfig</code> problem.</p>
<p>It&#8217;s a kind of a &#8220;pattern&#8221; and I will publish it in my &#8220;file patterns&#8221; series on this blog with more code comments.</p>
<h1>Example</h1>
<p>If we build upon Jay&#8217;s example, using the pattern above, we get:</p>
<p><code>AbstractFormPanel.js</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">AbstractFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">FormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     defaultType<span style="color: #339933;">:</span><span style="color: #3366CC;">'textfield'</span>
    <span style="color: #339933;">,</span>frame<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span>
    <span style="color: #339933;">,</span>width<span style="color: #339933;">:</span><span style="color: #CC0000;">300</span>
    <span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">200</span>
    <span style="color: #339933;">,</span>labelWidth<span style="color: #339933;">:</span><span style="color: #CC0000;">75</span>
    <span style="color: #339933;">,</span>submitUrl<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span>
    <span style="color: #339933;">,</span>submitT<span style="color: #339933;">:</span><span style="color: #3366CC;">'Submit'</span>
    <span style="color: #339933;">,</span>cancelT<span style="color: #339933;">:</span><span style="color: #3366CC;">'Cancel'</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// create config object</span>
        <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
            defaults<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>anchor<span style="color: #339933;">:</span><span style="color: #3366CC;">'-10'</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// build config</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildConfig</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// apply config</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initialConfig</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        MyApp.<span style="color: #660066;">AbstractFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
&nbsp;
    <span style="color: #339933;">,</span>buildConfig<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildItems</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildButtons</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildTbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildBbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildConfig</span>
&nbsp;
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">items</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
    <span style="color: #339933;">,</span>buildButtons<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">buttons</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
             text<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">submitT</span>
            <span style="color: #339933;">,</span>scope<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>
            <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onSubmit</span>
            <span style="color: #339933;">,</span>iconCls<span style="color: #339933;">:</span><span style="color: #3366CC;">'icon-disk'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             text<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">cancelT</span>
            <span style="color: #339933;">,</span>scope<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>
            <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onCancel</span>
            <span style="color: #339933;">,</span>iconCls<span style="color: #339933;">:</span><span style="color: #3366CC;">'icon-undo'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildButtons</span>
&nbsp;
    <span style="color: #339933;">,</span>buildTbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">tbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildTbar</span>
&nbsp;
    <span style="color: #339933;">,</span>buildBbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">bbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildBbar</span>
&nbsp;
    <span style="color: #339933;">,</span>onSubmit<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Ext.<span style="color: #660066;">MessageBox</span>.<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Submit'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">submitUrl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function onSubmit</span>
&nbsp;
    <span style="color: #339933;">,</span>onCancel<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">el</span>.<span style="color: #660066;">mask</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'This form is canceled'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function onCancel</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span></pre></div></div>

<p>Mention please that I moved hard-wired button texts to class properties. The reason is that this way we can easily localize (translate) these texts to another languages. I didn&#8217;t take care of messages of handlers though. You will do in your localizable applications, won&#8217;t you?</p>
<p><code>AddressFormPanel.js</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">AddressFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>MyApp.<span style="color: #660066;">AbstractFormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Edit address data'</span>
    <span style="color: #339933;">,</span>submitUrl<span style="color: #339933;">:</span><span style="color: #3366CC;">'addressAction.asp'</span>
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">items</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'address1'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'Address 1'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'address2'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'Address 2'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'city'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'city'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'combo'</span>
            <span style="color: #339933;">,</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'state'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'State'</span>
            <span style="color: #339933;">,</span>store<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'MD'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'VA'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'DC'</span><span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'numberfield'</span>
            <span style="color: #339933;">,</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'zip'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'Zip Code'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></div></div>

<p><code>NameFormPanel.js</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">NameFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>MyApp.<span style="color: #660066;">AbstractFormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Edit name data'</span>
    <span style="color: #339933;">,</span>submitUrl<span style="color: #339933;">:</span><span style="color: #3366CC;">'nameAction.asp'</span>
    <span style="color: #339933;">,</span>okT<span style="color: #339933;">:</span><span style="color: #3366CC;">'OK'</span>
&nbsp;
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">items</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'firstName'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'First Name'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'lastName'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'Last Name'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'middleName'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'Middle Name'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'datefield'</span>
            <span style="color: #339933;">,</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'dob'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'DOB'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//Extension</span>
    <span style="color: #339933;">,</span>buildButtons<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// let parent build buttons first</span>
        MyApp.<span style="color: #660066;">NameFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">buildButtons</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// tweak the submit button</span>
        config.<span style="color: #660066;">buttons</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">okT</span><span style="color: #339933;">;</span>
        config.<span style="color: #660066;">buttons</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">handler</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onOkBtn</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildButtons</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//Override</span>
    <span style="color: #339933;">,</span>onOkBtn<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        console.<span style="color: #660066;">info</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'OK btn pressed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function onOkBtn</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></div></div>

<p>With this setup, we can even create instance of AbstractForm panel directly passing some/all build functions inline:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> nameForm <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> MyApp.<span style="color: #660066;">AbstractFormPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
     title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Name Form Panel configured inline'</span>
    <span style="color: #339933;">,</span>width<span style="color: #339933;">:</span><span style="color: #CC0000;">300</span>
    <span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">200</span>
    <span style="color: #339933;">,</span>renderTo<span style="color: #339933;">:</span>Ext.<span style="color: #660066;">getBody</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">items</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'firstName'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'First Name'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'lastName'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'Last Name'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'middleName'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'Middle Name'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'datefield'</span>
            <span style="color: #339933;">,</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'dob'</span>
            <span style="color: #339933;">,</span>fieldLabel<span style="color: #339933;">:</span><span style="color: #3366CC;">'DOB'</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><i><b>Note:</b></i> Although the above works, it violates the rule of not instantiating an abstract class directly. It&#8217;s up to you if you will do it or not.</p>
<h1>Combining with &#8220;xtypes&#8221;</h1>
<p>Now, do not succumb to the temptation of &#8220;putting everything&#8221; in factory functions. Abstract classes are just a programming style, not an universal solvent.</p>
<p>Imagine, you have your own carefully crafted Submit and Cancel buttons so if you would &#8220;put everything&#8221; in the factory functions you would need to copy buttons configurations many times because also toolbars, grids, data views, etc can contain them.</p>
<p>Create extensions (xtypes) for those buttons instead. The following illustrates the approach:</p>
<p><code>SubmitButton.js</code></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">SubmitButton</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">Button</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Submit'</span>
    <span style="color: #339933;">,</span>iconCls<span style="color: #339933;">:</span><span style="color: #3366CC;">'icon-disk'</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        MyApp.<span style="color: #660066;">SubmitButton</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span>
&nbsp;
Ext.<span style="color: #660066;">reg</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'submitbutton'</span><span style="color: #339933;">,</span> MyApp.<span style="color: #660066;">SubmitButton</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></div></div>

<p><code>CancelButton.js</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">CancelButton</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">Button</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Cancel'</span>
    <span style="color: #339933;">,</span>iconCls<span style="color: #339933;">:</span><span style="color: #3366CC;">'icon-undo'</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        MyApp.<span style="color: #660066;">CancelButton</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span>
&nbsp;
Ext.<span style="color: #660066;">reg</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cancelbutton'</span><span style="color: #339933;">,</span> MyApp.<span style="color: #660066;">CancelButton</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></div></div>

<p>and <code>AbstractFormPanel.js</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #660066;">AbstractFormPanel</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">FormPanel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
     defaultType<span style="color: #339933;">:</span><span style="color: #3366CC;">'textfield'</span>
    <span style="color: #339933;">,</span>frame<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span>
    <span style="color: #339933;">,</span>width<span style="color: #339933;">:</span><span style="color: #CC0000;">300</span>
    <span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">200</span>
    <span style="color: #339933;">,</span>labelWidth<span style="color: #339933;">:</span><span style="color: #CC0000;">75</span>
    <span style="color: #339933;">,</span>submitUrl<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span>
    <span style="color: #339933;">,</span>initComponent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// create config object</span>
        <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
            defaults<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>anchor<span style="color: #339933;">:</span><span style="color: #3366CC;">'-10'</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// build config</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildConfig</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// apply config</span>
        Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initialConfig</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// call parent</span>
        MyApp.<span style="color: #660066;">AbstractFormPanel</span>.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function initComponent</span>
&nbsp;
    <span style="color: #339933;">,</span>buildConfig<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildItems</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildButtons</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildTbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buildBbar</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildConfig</span>
&nbsp;
    <span style="color: #339933;">,</span>buildItems<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">items</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildItems</span>
&nbsp;
    <span style="color: #339933;">,</span>buildButtons<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">buttons</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
             xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'submitbutton'</span>
            <span style="color: #339933;">,</span>scope<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>
            <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onSubmit</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
             xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'cancelbutton'</span>
            <span style="color: #339933;">,</span>scope<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>
            <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onCancel</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildButtons</span>
&nbsp;
    <span style="color: #339933;">,</span>buildTbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">tbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildTbar</span>
&nbsp;
    <span style="color: #339933;">,</span>buildBbar<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        config.<span style="color: #660066;">bbar</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function buildBbar</span>
&nbsp;
    <span style="color: #339933;">,</span>onSubmit<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Ext.<span style="color: #660066;">MessageBox</span>.<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Submit'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">submitUrl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function onSubmit</span>
&nbsp;
    <span style="color: #339933;">,</span>onCancel<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">el</span>.<span style="color: #660066;">mask</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'This form is canceled'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function onCancel</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo extend</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></div></div>

<p><b><i>Note:</i></b> The above buttons are far too simple to be extended in the real world but you get the point, right?</p>
<h1>Conclusion</h1>
<p>Abstract classes, as Jay Garcia defines and presents them, are a very useful ExtJS programming technique and if you use them in the information provided in this post your code will be clean, flexible and maintainable. That is what all we developers want.</p>
<p>Happy coding!</p>
<p>Further reading:</p>
<ol>
<li>
<a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/">Writing a Big Application in Ext</a>
</li>
<li><a href="http://tdg-i.com/364/abstract-classes-with-ext-js">Abstract classes with Ext JS</a>
</li>
</ol>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/know-how/factory-functions-in-ext-extensions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New Example &#8211; Grid in Card Layout</title>
		<link>http://blog.extjs.eu/examples/new-example-grid-in-card-layout/</link>
		<comments>http://blog.extjs.eu/examples/new-example-grid-in-card-layout/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 12:49:17 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[ext]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=540</guid>
		<description><![CDATA[<br/>Hi all,
I&#8217;ve just uploaded new example of Grid in Card Layout
Enjoy!
]]></description>
			<content:encoded><![CDATA[<br/><p>Hi all,</p>
<p>I&#8217;ve just uploaded new example of <a target="_blank" href="http://examples.extjs.eu/?ex=gridincard">Grid in Card Layout</a></p>
<p>Enjoy!</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/examples/new-example-grid-in-card-layout/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Convert DVD to iPhone Video with Subtitles and Chapters on Linux</title>
		<link>http://blog.extjs.eu/multimedia/how-to-convert-dvd-to-iphone-video-with-subtitles-and-chapters-on-linux/</link>
		<comments>http://blog.extjs.eu/multimedia/how-to-convert-dvd-to-iphone-video-with-subtitles-and-chapters-on-linux/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 21:02:44 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=506</guid>
		<description><![CDATA[<br/>iPhone can play video that contains multiple streams and chapters:

video
multiple audio streams (languages)
multiple subtitles (languages)
chapters for easy navigation

After some googling and many trials and errors I found a multiplatform software that can create videos with all the above features. The software is HandBrake. HandBrake for (openSUSE) Linux can be downloaded from Packman.
Let&#8217;s convert our DVD [...]]]></description>
			<content:encoded><![CDATA[<br/><p>iPhone can play video that contains multiple streams and chapters:</p>
<ul>
<li>video</li>
<li>multiple audio streams (languages)</li>
<li>multiple subtitles (languages)</li>
<li>chapters for easy navigation</li>
</ul>
<p>After some googling and many trials and errors I found a multiplatform software that can create videos with all the above features. The software is <a target="_blank" href="http://handbrake.fr">HandBrake</a>. HandBrake for (openSUSE) Linux can be downloaded from <a target="_blank" href="http://packman.links2linux.org">Packman</a>.</p>
<p>Let&#8217;s convert our DVD to the iPhone video. For that insert an original DVD in the drive, start HandBrake and select source.</p>
<p><a href="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-011.png"><img src="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-011.png" alt="dvd2ipod-01" title="dvd2ipod-01" width="600" class="aligncenter size-full wp-image-520" /></a></p>
<p>Select <i>iPhone &amp; iPod Touch</i> preset and type the file name and the destination directory.</p>
<p><a href="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-02.png"><img src="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-02.png" alt="dvd2ipod-02" title="dvd2ipod-02" width="600" class="aligncenter size-full wp-image-521" /></a></p>
<p>There is not too much to set on Video tab, however, you can play with quality if you want.</p>
<p><a href="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-03.png"><img src="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-03.png" alt="dvd2ipod-03" title="dvd2ipod-03" width="600" class="aligncenter size-full wp-image-522" /></a></p>
<p>In Audio tab, add as many audio tracks as you want:</p>
<p><a href="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-04.png"><img src="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-04.png" alt="dvd2ipod-04" title="dvd2ipod-04" width="600" class="aligncenter size-full wp-image-523" /></a></p>
<p>If you want to &#8220;burn&#8221; subtitles into video, just select one from the original DVD and you&#8217;re done. More difficult is if you want Closed Captioning subtitles (that can be turned off on iPhone). For that you need external files with subtitles in <code>srt</code> format. You can download them from <a target="_blank" href="http://opensubtitles.org">opensubtitles.org</a>. The problem can be that the downloaded subtitles may not be in sync with you video. I haven&#8217;t found a better way only to encode the DVD and, if subtitles are out of sync, use <a target="_blank" href="http://subcomposer.sourceforge.net">Subtitle Composer</a> to adjust the timing(s) and re-encode.</p>
<p><a href="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-05.png"><img src="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-05.png" alt="dvd2ipod-05" title="dvd2ipod-05" width="600" class="aligncenter size-full wp-image-524" /></a></p>
<p>Default settings in H.264 tab do not need any change.</p>
<p><a href="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-06.png"><img src="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-06.png" alt="dvd2ipod-06" title="dvd2ipod-06" width="600" class="aligncenter size-full wp-image-525" /></a></p>
<p>Rename chapters if you want. Names are sometimes on DVD covers, sometimes not.</p>
<p><a href="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-07.png"><img src="http://blog.extjs.eu/wp-content/uploads/2009/10/dvd2ipod-07.png" alt="dvd2ipod-07" title="dvd2ipod-07" width="600" class="aligncenter size-full wp-image-526" /></a></p>
<p>Start encoding, wait an hour or so and then download the resulting video to your iPhone with iTunes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/multimedia/how-to-convert-dvd-to-iphone-video-with-subtitles-and-chapters-on-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to extract subtitles from DVD</title>
		<link>http://blog.extjs.eu/multimedia/how-to-extract-subtitles-from-dvd/</link>
		<comments>http://blog.extjs.eu/multimedia/how-to-extract-subtitles-from-dvd/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 09:11:09 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Multimedia]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=504</guid>
		<description><![CDATA[<br/>
mencoder dvd://1 -oac copy -ovc copy -o /dev/null -vobsubout output -sid 1

Then use avidemux2_qt4
]]></description>
			<content:encoded><![CDATA[<br/>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mencoder dvd:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #000000;">1</span> <span style="color: #660033;">-oac</span> copy <span style="color: #660033;">-ovc</span> copy <span style="color: #660033;">-o</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #660033;">-vobsubout</span> output <span style="color: #660033;">-sid</span> <span style="color: #000000;">1</span></pre></div></div>

<p>Then use <code>avidemux2_qt4</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/multimedia/how-to-extract-subtitles-from-dvd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Keeping modified records of EditorGridPanel while paging</title>
		<link>http://blog.extjs.eu/patterns/code-patterns/keeping-modified-records-of-editorgridpanel-while-paging/</link>
		<comments>http://blog.extjs.eu/patterns/code-patterns/keeping-modified-records-of-editorgridpanel-while-paging/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 08:59:44 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Code Patterns]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[Know-how]]></category>
		<category><![CDATA[pattern]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=498</guid>
		<description><![CDATA[<br/>If you modify records of an editable grid with paging and if you then page-out, your changes are lost. Well, they are not lost in fact unless you have set pruneModifiedRecords:true on the strore. The modifications are still available so we just need to apply them. Here is the code fragment that does it:

var grid [...]]]></description>
			<content:encoded><![CDATA[<br/><p>If you modify records of an editable grid with paging and if you then page-out, your changes are lost. Well, they are not lost in fact unless you have set <code><a target="_blank" href="http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Store&#038;member=pruneModifiedRecords">pruneModifiedRecords:true</a></code> on the strore. The modifications are still available so we just need to apply them. Here is the code fragment that does it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">EditorGridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    store<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
         listeners<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
            load<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>scope<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> fn<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>store<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #006600; font-style: italic;">// loop through modified records</span>
                <span style="color: #003366; font-weight: bold;">var</span> modified <span style="color: #339933;">=</span> store.<span style="color: #660066;">getModifiedRecords</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> modified.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                    <span style="color: #006600; font-style: italic;">// see if we have a record with same id </span>
                    <span style="color: #006600; font-style: italic;">// and apply changes if yes</span>
                    <span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> store.<span style="color: #660066;">getById</span><span style="color: #009900;">&#40;</span>modified<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #003366; font-weight: bold;">var</span> changes <span style="color: #339933;">=</span> modified<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getChanges</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>p <span style="color: #000066; font-weight: bold;">in</span> changes<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>changes.<span style="color: #660066;">hasOwnProperty</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                r.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span> changes<span style="color: #009900;">&#91;</span>p<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                            <span style="color: #009900;">&#125;</span>
                        <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo changes loop</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo modified loop</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo load listener</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo listeners</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// rest of store configuration</span>
&nbsp;
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// rest of grid configuration</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// eo grid</span></pre></div></div>

<p><b>pruneModifiedRecords must be false (the default) for this to work.</b></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/patterns/code-patterns/keeping-modified-records-of-editorgridpanel-while-paging/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New Example &#8211; Ext.ux.MsgBus Demo</title>
		<link>http://blog.extjs.eu/examples/new-example-ext-ux-msgbus-demo/</link>
		<comments>http://blog.extjs.eu/examples/new-example-ext-ux-msgbus-demo/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 21:48:38 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=490</guid>
		<description><![CDATA[<br/>Hi there,
I&#8217;ve just uploaded demo of Ext.ux.MsgBus Plugin at http://examples.extjs.eu/?ex=msgbus.
Enjoy!
]]></description>
			<content:encoded><![CDATA[<br/><p>Hi there,</p>
<p>I&#8217;ve just uploaded demo of <a href="http://blog.extjs.eu/plugins/ext-ux-msgbus-plugin/">Ext.ux.MsgBus Plugin</a> at <a href="http://examples.extjs.eu/?ex=msgbus">http://examples.extjs.eu/?ex=msgbus</a>.</p>
<p>Enjoy!</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/examples/new-example-ext-ux-msgbus-demo/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ext.ux.MsgBus Plugin</title>
		<link>http://blog.extjs.eu/plugins/ext-ux-msgbus-plugin/</link>
		<comments>http://blog.extjs.eu/plugins/ext-ux-msgbus-plugin/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 12:45:10 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=473</guid>
		<description><![CDATA[<br/>Recently I&#8217;ve been looking for a better way of inter-component communication in Ext so I&#8217;ve read a couple of posts with Message Bus implementations, I&#8217;ve skimmed over OpenAjax Hub page but I haven&#8217;t found anything suitable for my needs.
The first approach was Simple Message Bus Example but that is more concept proof than a really [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Recently I&#8217;ve been looking for a better way of inter-component communication in Ext so I&#8217;ve read a couple of posts with Message Bus implementations, I&#8217;ve skimmed over <a target="_blank" href="http://openajax.org">OpenAjax Hub</a> page but I haven&#8217;t found anything suitable for my needs.</p>
<p>The first approach was <a target="_blank" href="http://blog.extjs.eu/examples/new-example-simple-message-bus">Simple Message Bus Example</a> but that is more concept proof than a really usable way in production environment.</p>
<p>I like the concept of message subjects (topics) as <a target="_blank" href="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Topic_Names">dot separated sequence of tokens</a> with the ability to subscribe to messages with specific subjects and with wildcard support.</p>
<p>For example, if a component would subscribe to the subject <code>eu.extjs.desktop.**</code> it would receive message with subject <code>eu.extjs.desktop.wallpaper.set</code> but it wouldn&#8217;t receive message <code>eu.extjs.taskbar.hide</code>.</p>
<p>So this plugin was born.</p>
<p>Ext.ux.MsgBus fits in any component that is descendant of Ext.util.Observable and it does not need any other changes/overrides. You would stick it only into the components that must participate in bus messaging. It adds <code>subscribe</code> and <code>publish</code> methods to the component.</p>
<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> p <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Panel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
     plugins<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'msgbus'</span><span style="color: #009900;">&#93;</span>
    <span style="color: #339933;">,</span>onWallpaper<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>subject<span style="color: #339933;">,</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// do something</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #006600; font-style: italic;">// the rest of config</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
p.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'eu.extjs.desktop.wallpaper.**'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>fn<span style="color: #339933;">:</span>p.<span style="color: #660066;">onWallpaper</span><span style="color: #339933;">,</span> single<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above would call p.onWallpaper callback once upon the receipt of a &#8220;wallpaper&#8221; message.</p>
<p>Other example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">p.<span style="color: #660066;">publish</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'eu.extjs.this.panel.move'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>oldx<span style="color: #339933;">:</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span> oldy<span style="color: #339933;">:</span><span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> x<span style="color: #339933;">:</span><span style="color: #CC0000;">300</span><span style="color: #339933;">,</span> y<span style="color: #339933;">:</span><span style="color: #CC0000;">400</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I haven&#8217;t tested it fully yet so take it more as an initial idea than as a bullet-proof, worldwide-tested code. Also, I didn&#8217;t try in any means to implement OpenAjax standards and use this plugin for an inter library communication. Consider it as a one possibility of intra-Ext, inter-component communication.</p>
<p>Any comments and/or bug reports are welcome.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// vim: sw=4:ts=4:nu:nospell:fdc=4</span>
<span style="color: #006600; font-style: italic;">/**
 * Message Bus Plugin
 *
 * @author    Ing. Jozef Sakáloš
 * @copyright (c) 2009, by Ing. Jozef Sakáloš
 * @date      19. September 2009
 * @version   $Id: Ext.ux.MsgBus.js 29 2009-09-23 09:51:55Z jozo $
 *
 * @license Ext.ux.MsgBus.js is licensed under the terms of the Open Source
 * LGPL 3.0 license. Commercial use is permitted to the extent that the 
 * code/component(s) do NOT become part of another Open Source or Commercially
 * licensed development library or toolkit without explicit permission.
 * 
 * License details: http://www.gnu.org/licenses/lgpl.html
 */</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/*global Ext,window */</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * @class Ext.ux.MsgBus
 *
 * Creates new Ext.ux.MsgBus object
 * @constructor
 * @param {Object} config The config object
 */</span>
Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">MsgBus</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> config<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo constructor</span>
&nbsp;
Ext.<span style="color: #660066;">override</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">MsgBus</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">/**
     * @cfg {String} busName Name of the global Observable instance
     */</span>
     busName<span style="color: #339933;">:</span><span style="color: #3366CC;">'Ext.ux.Bus'</span>
    <span style="color: #006600; font-style: italic;">/**
     * @private
     */</span>
    <span style="color: #339933;">,</span>bus<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span>
    <span style="color: #006600; font-style: italic;">/**
     * Initializes the plugin and component
     * @private
     */</span>
    <span style="color: #339933;">,</span>init<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>cmp<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">cmp</span> <span style="color: #339933;">=</span> cmp<span style="color: #339933;">;</span>
        cmp.<span style="color: #660066;">bus</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getBus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        cmp.<span style="color: #660066;">bus</span>.<span style="color: #660066;">addEvents</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        cmp.<span style="color: #660066;">subs</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">applyConfig</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function init</span>
    <span style="color: #006600; font-style: italic;">// {{{</span>
    <span style="color: #006600; font-style: italic;">/**
     * Returns or creates the global Observable instance
     * @private
     */</span>
    <span style="color: #339933;">,</span>getBus<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> bus <span style="color: #339933;">=</span> window<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">busName</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> last <span style="color: #339933;">=</span> a.<span style="color: #660066;">pop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Ext.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Ext.<span style="color: #660066;">isObject</span><span style="color: #009900;">&#40;</span>bus<span style="color: #009900;">&#91;</span>n<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                bus <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                bus <span style="color: #339933;">=</span> bus<span style="color: #009900;">&#91;</span>n<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span> <span style="color: #339933;">===</span> bus<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Ext.<span style="color: #660066;">ns</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">busName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getBus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>bus<span style="color: #009900;">&#91;</span>last<span style="color: #009900;">&#93;</span> <span style="color: #000066; font-weight: bold;">instanceof</span> Ext.<span style="color: #660066;">util</span>.<span style="color: #660066;">Observable</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            bus<span style="color: #009900;">&#91;</span>last<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">util</span>.<span style="color: #660066;">Observable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> bus<span style="color: #009900;">&#91;</span>last<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function getBus</span>
    <span style="color: #006600; font-style: italic;">// }}}</span>
    <span style="color: #006600; font-style: italic;">// {{{</span>
    <span style="color: #006600; font-style: italic;">/**
     * Creates RegExp for message filtering.
     * Override it if you need another logic.
     * @param {String} subject The message subject
     * @return {RegExp} RegExp used for message filtering
     */</span>
    <span style="color: #339933;">,</span>getFilterRe<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>subject<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> subject.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> last <span style="color: #339933;">=</span> a.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
        a<span style="color: #009900;">&#91;</span>last<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'**'</span> <span style="color: #339933;">===</span> a<span style="color: #009900;">&#91;</span>last<span style="color: #009900;">&#93;</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">'.*'</span> <span style="color: #339933;">:</span> a<span style="color: #009900;">&#91;</span>last<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> re <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^\w+$/</span><span style="color: #339933;">;</span>
        Ext.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>token<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>re.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>token<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #3366CC;">'*'</span> <span style="color: #339933;">!==</span> token <span style="color: #339933;">&amp;&amp;</span> <span style="color: #3366CC;">'.*'</span> <span style="color: #339933;">!==</span> token<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #3366CC;">'Invalid subject: '</span> <span style="color: #339933;">+</span> subject<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'*'</span> <span style="color: #339933;">===</span> token<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>w+'</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'^'</span> <span style="color: #339933;">+</span> a.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>.'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'$'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function getFilter</span>
    <span style="color: #006600; font-style: italic;">// }}}</span>
    <span style="color: #006600; font-style: italic;">// {{{</span>
    <span style="color: #006600; font-style: italic;">/**
     * Applies new methods to the component
     * @private
     */</span>
    <span style="color: #339933;">,</span>applyConfig<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Ext.<span style="color: #660066;">applyIf</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">cmp</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">/**
             * Subscribes to messages (parent component method)
             * @param {String} subject Dotted notation subject with wildcards.
             * See http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Topic_Names
             * @param {Object} config Same as addListener config object
             * @return {Boolean} success true on success, false on failure (subscription exists)
             */</span>
             subscribe<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>subject<span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                 <span style="color: #003366; font-weight: bold;">var</span> sub <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">subs</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sub<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                config <span style="color: #339933;">=</span> config <span style="color: #339933;">||</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                config.<span style="color: #660066;">filter</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getFilterRe</span><span style="color: #009900;">&#40;</span>subject<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">subs</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>config<span style="color: #339933;">:</span>config<span style="color: #339933;">,</span> fn<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">filterMessage</span>.<span style="color: #660066;">createDelegate</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>config<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">bus</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">subs</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">fn</span><span style="color: #339933;">,</span> config.<span style="color: #660066;">scope</span> <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">/**
             * Unsubscribes from messages (parent component method)
             * @param {String} subject Dotted notation subject with wildcards.
             * @return {Boolean} success true on success, false on failure (nonexistent subscription)
             */</span>
            <span style="color: #339933;">,</span>unsubscribe<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>subject<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> sub <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">subs</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>sub<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">bus</span>.<span style="color: #660066;">un</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #339933;">,</span> sub.<span style="color: #660066;">fn</span><span style="color: #339933;">,</span> sub.<span style="color: #660066;">scope</span> <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> sub.<span style="color: #660066;">config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">delete</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">subs</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                sub <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function unsubscribe</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">/**
             * Publishes the message (parent component method)
             * @param {String} subject Message subject
             * @param {Mixed} message Message body, most likely an object
             */</span>
            <span style="color: #339933;">,</span>publish<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>subject<span style="color: #339933;">,</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getFilterRe</span><span style="color: #009900;">&#40;</span>subject<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">bus</span>.<span style="color: #660066;">fireEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #339933;">,</span> subject<span style="color: #339933;">,</span> message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function publish</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">/**
             * Returns current subscriptions
             * @return {Object} subscriptions
             */</span>
            <span style="color: #339933;">,</span>getSubscriptions<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">subs</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">/**
             * @private
             */</span>
            <span style="color: #339933;">,</span>getFilterRe<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getFilterRe</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">/**
             * Filters incoming messages
             * @private
             */</span>
            <span style="color: #339933;">,</span>filterMessage<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>subject<span style="color: #339933;">,</span> message<span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>config.<span style="color: #660066;">filter</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>subject<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #009900;">&#40;</span>config.<span style="color: #660066;">fn</span> <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onMessage</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>config.<span style="color: #660066;">scope</span> <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> subject<span style="color: #339933;">,</span> message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function filterMessage</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">/**
             * Default message processing function
             * @param {String} subject The message subject
             * @param {Mixed} message The message body
             */</span>
            <span style="color: #339933;">,</span>onMessage<span style="color: #339933;">:</span>Ext.<span style="color: #660066;">emptyFn</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function applyConfig</span>
    <span style="color: #006600; font-style: italic;">// }}}</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo override</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// register ptype</span>
Ext.<span style="color: #660066;">preg</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'msgbus'</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">MsgBus</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></div></div>

<p>Enjoy!</p>
<p>The accompanying example: <a target="_blank" href="http://examples.extjs.eu/?ex=msgbus">Ext.ux.MsgBus</a></p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/plugins/ext-ux-msgbus-plugin/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>New Example &#8211; Simple Message Bus</title>
		<link>http://blog.extjs.eu/examples/new-example-simple-message-bus/</link>
		<comments>http://blog.extjs.eu/examples/new-example-simple-message-bus/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 20:02:45 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Examples]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=465</guid>
		<description><![CDATA[<br/>Hi all,
I&#8217;ve just uploaded very simple, extremely simple, example of how to implement Message Bus in Ext using the global Ext.util.Observable instance.
Enjoy!
Simple Message Bus Example
See also: Ext.ux.MsgBus Plugin
]]></description>
			<content:encoded><![CDATA[<br/><p>Hi all,</p>
<p>I&#8217;ve just uploaded very simple, extremely simple, example of how to implement Message Bus in Ext using the global Ext.util.Observable instance.</p>
<p>Enjoy!</p>
<p><a target="_blank" href="http://examples.extjs.eu/?ex=simplebus">Simple Message Bus Example</a></p>
<p>See also: <a href="http://blog.extjs.eu/plugins/ext-ux-msgbus-plugin/">Ext.ux.MsgBus Plugin</a></p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/examples/new-example-simple-message-bus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What the hell is mon and mun?</title>
		<link>http://blog.extjs.eu/know-how/what-the-hell-is-mon-and-mun/</link>
		<comments>http://blog.extjs.eu/know-how/what-the-hell-is-mon-and-mun/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 00:31:51 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Know-how]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=446</guid>
		<description><![CDATA[<br/>I&#8217;ve run across the following code in some of Ext 3.x examples:

this.mon&#40;toolsUl, 'click', this.onClick, this&#41;;

Looks like event handler installation but what it really does anyway?
So I delved into the code and remembered ExtJS Conference and now it is clear to me.
Imagine you create a component and then you need to install an event handler, for [...]]]></description>
			<content:encoded><![CDATA[<br/><p>I&#8217;ve run across the following code in some of Ext 3.x examples:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">mon</span><span style="color: #009900;">&#40;</span>toolsUl<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onClick</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Looks like event handler installation but what it really does anyway?</p>
<p>So I delved into the code and remembered ExtJS Conference and now it is clear to me.</p>
<p>Imagine you create a component and then you need to install an event handler, for example, on its body. Something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> handler <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'You clicked my body'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> p <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Panel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
     renderTo<span style="color: #339933;">:</span>Ext.<span style="color: #660066;">getBody</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">,</span>title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Panel with a listener on the body'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
p.<span style="color: #660066;">body</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Easy enough, we&#8217;ve done something like this many times. But, if the panel is ever to be destroyed we need to remove this listener ourselves as Ext knows nothing about it.</p>
<p> Something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> p <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Panel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
     renderTo<span style="color: #339933;">:</span>Ext.<span style="color: #660066;">getBody</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">,</span>title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Panel with a listener on the body'</span>
    <span style="color: #339933;">,</span>beforeDestroy<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">body</span>.<span style="color: #660066;">un</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>
If we install our listener as inline function, such as:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">p.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'You clicked my body'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</p>
<p>then it is impossible to remove this listener selectively, you would need to use</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">p.<span style="color: #660066;">body</span>.<span style="color: #660066;">removeAllListeners</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>to remove <i>all</i> body listeners.</p>
<p>Now, if we use <code>mon</code> (m stands for &#8220;managed&#8221;) this way</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">p.<span style="color: #660066;">mon</span><span style="color: #009900;">&#40;</span>p.<span style="color: #660066;">body</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>then the listener is automatically removed by Ext on panel destroy. Nice, isn&#8217;t it? Saves a lot of our work and also handles our laziness or forgetfulness about destroying and cleanups of components.</p>
<p>
Mind the first argument, that is the element to install the listener to. It can, but not necessarily have to be within the component. Also remember that when you destroy <code>p</code> Ext only removes listener from the element so if the element is outside of <code>p</code> you need to remove it yourself if it is not necessary anymore.
</p>
<p>Should you ever need to remove the listener installed by <code>mon</code> you use <code>mun</code> with same arguments. You cannot selectively remove inline listeners.</p>
<p><code>mon</code> and <code>mun</code> are defined in Component so you can use them from Component down the descendant classes chain.</p>
<p>
<span style="color:#c00000;font-size:14px;font-weight:bold">Warning! <code>mon</code> and <code>mun</code> are not documented (yet?) so there is still (a little) risk that they will change or will be removed.</span>
</p>
<p>&nbsp;</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/know-how/what-the-hell-is-mon-and-mun/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Mastering Ext.Direct, Part 3</title>
		<link>http://blog.extjs.eu/know-how/mastering-ext-direct-part-3/</link>
		<comments>http://blog.extjs.eu/know-how/mastering-ext-direct-part-3/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 12:20:37 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Know-how]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=421</guid>
		<description><![CDATA[<br/>]]></description>
			<content:encoded><![CDATA[<br/><h4><a href="http://blog.extjs.eu/know-how/mastering-ext-direct-part-2"><<< Mastering Ext.Direct, Part 2</a></h4>
<h1>Processing responses</h1>
<p>As I&#8217;ve already said, you cannot use the return value of an API function call as result is not know at the moment of the call return. It is never stressed enough that
<p><b>Ext.Direct calls are ASYNCHRONOUS</b>.</p>
<p>Therefore, all Ext.Direct created API functions, for example <code>Example.Car.go()</code> take one extra argument in addition to arguments you have specified in server-side class definition. That argument is <b>callback function</b>.
</p>
<p>
In our example, <code>Example.Car.go()</code> takes one argument, <code>speed</code> per server side method definition, however, it takes two in fact: <code>Example.Car.go(speed, callback)</code>
</p>
<p>
Let&#8217;s call it with a callback to test it. Type in the Firebug console:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">go</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">80</span><span style="color: #339933;">,</span> console.<span style="color: #660066;">info</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><code>console.info</code> is a function that prints its arguments in a human readable form. We use it as the callback so we see:</p>
<ul>
<li>that it really gets called when the response arrives</li>
<li>which arguments Ext.Direct passes to the callback</li>
</ul>
<p>
As you can see, the callback is called with two arguments:</p>
<ul>
<li><code>response</code> &#8211; it is that what is returned by the server-side <code>Car.go()</code> method. It can be string (as in our example), boolean, object, array or void (nothing).</li>
<li><code>e</code> &#8211; it is <a target="_blank" href="http://www.extjs.com/deploy/dev/docs/?class=Ext.Direct&#038;member=eventTypes">Ext.Direct.Event</a> object or, being more specific, Ext.Direct.RemotingEvent.
</ul>
</p>
<p>
The event <code>e</code> has some useful properties and methods, most important of them are:</p>
<ul>
<li><code>status</code> is <code>true</code> if the call was successful, <code>false</code> if the call failed</li>
<li><code>result</code> contains same value as the first argument &#8211; it is server response data</li>
<li><code>type</code> is <code>rpc</code> in our example but it also can be <code>exception</code> or others
<li><code>action</code> is the class name</li>
<li><code>method</code> is name of the method called</li>
<li><code>getTransaction()</code> is method to retrieve the transaction used in this server round trip. You would use it if you want more data on the transaction.
</ul>
</p>
<h1>Processing exceptions</h1>
<p>Let&#8217;s call go method again:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">go</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">300</span><span style="color: #339933;">,</span> console.<span style="color: #660066;">info</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The callback is called as before but the arguments differ:</p>
<ul>
<li><code>response</code> is <code>undefined</code> &#8211; no data from server</li>
<li><code>e</code> has type <code>exception</code> and has property <code>message</code> that contains error message text</li>
</ul>
<h1>An example application</h1>
<p>That is almost all we need to know to start using Ext.Direct in an application. I&#8217;ve written a simple one so you have something to play with.</p>
<p>First, create file <code>example.js</code> with the following content:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * Mastering Ext.Direct example script
 *
 * @author     Ing. Jozef Sakalos
 * @copyright  (c) 2009, by Ing. Jozef Sakalos
 * @date       16. September 2009
 * @version    1.0
 * @revision   $Id$
 */</span>
&nbsp;
Ext.<span style="color: #660066;">BLANK_IMAGE_URL</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'ext/resources/images/default/s.gif'</span><span style="color: #339933;">;</span>
&nbsp;
Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">/**
     * This function is called when Ext.Direct request
     * response arrives from the server.
     *
     * @param {String/Object/Array/Null} response 
     * That what is returned by server method
     * @param {Ext.Direct.RemotingEvent/Ext.Direct.ExceptionEvent} e 
     */</span>
    <span style="color: #003366; font-weight: bold;">var</span> callback <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #339933;">,</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// uncomment if you want to inspect arguments in Firebug Console</span>
<span style="color: #006600; font-style: italic;">//        console.log(response, e);</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">status</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;b&gt;Success&lt;/b&gt;'</span>
        <span style="color: #003366; font-weight: bold;">var</span> text <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// success handling - e.status is success flag: </span>
        <span style="color: #006600; font-style: italic;">// true is success, false is failure</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">===</span> e.<span style="color: #000066;">status</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// response argument is same as e.result</span>
            text <span style="color: #339933;">=</span> response<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// failure handling</span>
        <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">status</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;b&gt;&lt;i&gt;Failure&lt;/i&gt;&lt;/b&gt;'</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// in the case of an exception, we don't have response but message</span>
            text <span style="color: #339933;">=</span> e.<span style="color: #660066;">message</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// grab the center body</span>
        <span style="color: #003366; font-weight: bold;">var</span> body <span style="color: #339933;">=</span> win.<span style="color: #660066;">items</span>.<span style="color: #660066;">itemAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">body</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// display the response</span>
        body.<span style="color: #660066;">createChild</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
             tag<span style="color: #339933;">:</span><span style="color: #3366CC;">'div'</span>
            <span style="color: #339933;">,</span>cls<span style="color: #339933;">:</span><span style="color: #3366CC;">'response'</span>
            <span style="color: #339933;">,</span>html<span style="color: #339933;">:</span><span style="color: #000066;">status</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">': '</span> <span style="color: #339933;">+</span> text
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// scroll down</span>
        body.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'top'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100000</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
    <span style="color: #006600; font-style: italic;">// create Ext.Direct test window</span>
    <span style="color: #003366; font-weight: bold;">var</span> win <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Window</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
         title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Mastering Ext.Direct by Saki'</span>
        <span style="color: #339933;">,</span>width<span style="color: #339933;">:</span><span style="color: #CC0000;">600</span>
        <span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">400</span>
        <span style="color: #339933;">,</span>closable<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span>
        <span style="color: #339933;">,</span>layout<span style="color: #339933;">:</span><span style="color: #3366CC;">'border'</span>
        <span style="color: #339933;">,</span>border<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span>
        <span style="color: #339933;">,</span>items<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// west region with buttons</span>
             region<span style="color: #339933;">:</span><span style="color: #3366CC;">'west'</span>
            <span style="color: #339933;">,</span>width<span style="color: #339933;">:</span><span style="color: #CC0000;">160</span>
            <span style="color: #339933;">,</span>minSize<span style="color: #339933;">:</span><span style="color: #CC0000;">160</span>
            <span style="color: #339933;">,</span>split<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span>
            <span style="color: #339933;">,</span>defaults<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>minWidth<span style="color: #339933;">:</span><span style="color: #CC0000;">120</span><span style="color: #009900;">&#125;</span>
            <span style="color: #339933;">,</span>layout<span style="color: #339933;">:</span><span style="color: #3366CC;">'table'</span>
            <span style="color: #339933;">,</span>bodyStyle<span style="color: #339933;">:</span><span style="color: #3366CC;">'padding:20px'</span>
            <span style="color: #339933;">,</span>layoutConfig<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>columns<span style="color: #339933;">:</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> tableAttrs<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>style<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>width<span style="color: #339933;">:</span><span style="color: #3366CC;">'100%'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span>
            <span style="color: #339933;">,</span>items<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
                 xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'button'</span>
                <span style="color: #339933;">,</span>text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Car.start()'</span>
&nbsp;
                <span style="color: #006600; font-style: italic;">// a delegate is needed if we want to pass arguments</span>
                <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span>Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">start</span>.<span style="color: #660066;">createDelegate</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>callback<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
                 xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'button'</span>
                <span style="color: #339933;">,</span>text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Car.go(80)'</span>
&nbsp;
                <span style="color: #006600; font-style: italic;">// a delegate is needed if we want to pass arguments</span>
                <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span>Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">go</span>.<span style="color: #660066;">createDelegate</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">80</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
                 xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'button'</span>
                <span style="color: #339933;">,</span>text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Car.go(250)'</span>
&nbsp;
                <span style="color: #006600; font-style: italic;">// a delegate is needed if we want to pass arguments</span>
                <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span>Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">go</span>.<span style="color: #660066;">createDelegate</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">250</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
                 xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'button'</span>
                <span style="color: #339933;">,</span>text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Car.stop()'</span>
&nbsp;
                <span style="color: #006600; font-style: italic;">// a delegate is needed if we want to pass arguments</span>
                <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span>Example.<span style="color: #660066;">Car</span>.<span style="color: #000066;">stop</span>.<span style="color: #660066;">createDelegate</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>callback<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
                 xtype<span style="color: #339933;">:</span><span style="color: #3366CC;">'button'</span>
                <span style="color: #339933;">,</span>text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Send All'</span>
&nbsp;
                <span style="color: #006600; font-style: italic;">// another option is inline function that executes calls</span>
                <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                    <span style="color: #006600; font-style: italic;">// the following calls will be combined in one request</span>
                    Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span>callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">go</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">80</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    Example.<span style="color: #660066;">Car</span>.<span style="color: #660066;">go</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">250</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    Example.<span style="color: #660066;">Car</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span>callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// responses are displayed here</span>
             region<span style="color: #339933;">:</span><span style="color: #3366CC;">'center'</span>
            <span style="color: #339933;">,</span>autoScroll<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span>
            <span style="color: #339933;">,</span>tbar<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'-&gt;'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
                text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Clear'</span>
               <span style="color: #339933;">,</span>handler<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>win.<span style="color: #660066;">items</span>.<span style="color: #660066;">itemAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">body</span>.<span style="color: #660066;">update</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    win.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></div></div>

</p>
<p>
Then tune your <code>index.php</code> so that it reads:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;?require_once<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;config.php&quot;</span><span style="color: #66cc66;">&#41;</span>;?&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ext/resources/css/ext-all.css&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ext/adapter/ext/ext-base.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ext/ext-all-debug.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;page-title&quot;</span>&gt;</span>Mastering Ext.Direct by Saki<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span>
      .x-table-layout-cell {
        height:40px;
        text-align:center;
        vertical-align:middle;
    }
    .x-table-layout-cell table {
        margin:auto
    }
    .response {
        padding:4px 0 4px 20px;
        font-size:13px;
    }
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;api.php&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
      Ext.Direct.addProvider(Example.API);
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;example.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

</p>
<h1>Conclusion</h1>
<p>Good! Play with Ext.Direct and let me know what you would like to have in next parts.<br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="js02@aariadne.com" /><input type="hidden" name="item_number" value="Blog Donation" /><input type="hidden" name="currency_code" value="EUR" /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" /></div></form></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.extjs.eu/know-how/mastering-ext-direct-part-3/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
