<?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 &#187; plugin</title>
	<atom:link href="http://blog.extjs.eu/tag/plugin/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>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>Extension or Plugin?</title>
		<link>http://blog.extjs.eu/know-how/extension-or-plugin/</link>
		<comments>http://blog.extjs.eu/know-how/extension-or-plugin/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 01:05:26 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[Know-how]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=64</guid>
		<description><![CDATA[<br/>Preface
I believe that many of Ext users have already thought about adding some custom functionality that is not present in core Ext Library to a class. Something that is specific to their applications or not that specific so that others could also be interested in such feature.
OK, we have the idea, we know what the [...]]]></description>
			<content:encoded><![CDATA[<br/><h1>Preface</h1>
<p>I believe that many of Ext users have already thought about adding some custom functionality that is not present in core Ext Library to a class. Something that is specific to their applications or not that specific so that others could also be interested in such feature.</p>
<p>OK, we have the idea, we know what the new code should do, we even know how to write it, but <i>what</i> should we write? An Extension or a Plugin?</p>
<h1>Extensions and Plugins</h1>
<p>The fact we are talking about them together and the fact that we can be even indecisive which one to use infers that they must have something in common. True, they have. They both <i>add</i> some functionality to an existing library or <i>modify</i> a feature of the library.</p>
<p>Neither extension nor plugin can exist standalone; they have to have a component, a class, they extend or plug into.</p>
<h1>Extension</h1>
<p>An extension (in Ext world) is a <a href="http://en.wikipedia.org/wiki/Inheritance_%28computer_science%29" target="_blank">derived class</a> in fact. Let&#8217;s imagine we have a basic class with some general methods to which we want to add some more specific methods. So, using the inheritance framework of an library or a language we <b>create new class</b> that contains methods of both basic class and new added methods.</p>
<p>We choose an <b>existing</b> Ext class, we extend it using <b><code>Ext.extend</code></b> function and the result is <b>new</b> class with <b>new</b> name. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">MyExtension <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">Panel</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/* object with new properties and methods */</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Later on, when we need an object:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myExtension <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> MyExtension<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/* optional configuration object */</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>Plugin</h1>
<p>Plugin does not need any exiting Ext class to exist. Although plugins often extend <b><code>Ext.util.Observable</code></b> it is not a must; they can be written from scratch. Sure, writing a plugin without having a target we want to plug it in has no sense so we always write plugins <b>for an existing</b> Ext class: panel, form, grid, data view, etc.</p>
<p>For example, we create plugin as:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">MyPlugin <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;">/* code */</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And then we use it this way:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myPanel <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: #003366; font-weight: bold;">new</span> MyPlugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/* optional config object */</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span>
    <span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">// rest of myPanel configuration</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>Extension or Plugin?</h1>
<p>It depends&#8230; You can often achieve same result with extension or with plugin. Sometimes it is only that programmer likes plugins more so he writes a plugin or he likes extensions more so he writes an extension. However, plugins are more suitable for adding smaller features and extensions are more suitable for adding more complex functionalities. Plugins can be easily removed from components, extensions are usually more tied to applications.</p>
<h1>Summary</h1>
<ul>
<li>
An <b>extension</b> is a <b>new</b> class with a <b>new</b> name, based on an existing base class and created at <b>definition</b> time. Extension must be <b>instantiated</b> as any other class to work.</li>
<li><b>Plugin</b> plugs into an existing class, is easily removed, is defined during definition time and is initialized during base class <b>initialization</b>.</li>
</ul>
<h1>Further reading</h1>
<ul>
<li><a href="http://extjs.com/learn/Tutorial:Extending_Ext2_Class" target="_blank">Extending an Ext Class</a></lil>
<li><a href="http://extjs.com/learn/Tutorial:Writing_Ext_2_Plugins" target="_blank">Writing an Ext Plugin</a></li>
</ul>
<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/extension-or-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Plugin File Pattern</title>
		<link>http://blog.extjs.eu/patterns/file-patters/javascript-plugin-file-pattern/</link>
		<comments>http://blog.extjs.eu/patterns/file-patters/javascript-plugin-file-pattern/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 01:37:23 +0000</pubDate>
		<dc:creator>Saki</dc:creator>
				<category><![CDATA[File Patters]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://blog.extjs.eu/?p=13</guid>
		<description><![CDATA[<br/>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// vim: sw=4:ts=4:nu:nospell:fdc=4
/**
 * A Plugin
 *
 * @author    Ing. Jozef Sakáloš
 * @copyright (c) 2008, by Ing. Jozef Sakáloš
 * @date      3. April 2008
 * @version   $Id$
 *
 * @license plugin.js is licensed under the terms of the Open Source
 * LGPL 3.0 license. [...]]]></description>
			<content:encoded><![CDATA[<br/>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td 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;">/**
 * A Plugin
 *
 * @author    Ing. Jozef Sakáloš
 * @copyright (c) 2008, by Ing. Jozef Sakáloš
 * @date      3. April 2008
 * @version   $Id$
 *
 * @license plugin.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 */</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * @class APlugin
 * @extends Ext.util.Observable
 *
 * Creates new APlugin object
 * @constructor
 * @param {Object} config The config object
 */</span>
APlugin <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: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// call parent</span>
    APlugin.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">constructor</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: #339933;">;</span> <span style="color: #006600; font-style: italic;">// eo constructor</span>
&nbsp;
Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>APlugin<span style="color: #339933;">,</span> Ext.<span style="color: #660066;">util</span>.<span style="color: #660066;">Observable</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// defaults - can be configured from outside</span>
&nbsp;
    init<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>parent<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;">parent</span> <span style="color: #339933;">=</span> parent<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// rest of plugin init code</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #006600; font-style: italic;">// eo function init</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// other plugin functions</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;">// register xtype</span>
Ext.<span style="color: #660066;">reg</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'apluginxtype'</span><span style="color: #339933;">,</span> APlugin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// eof</span></pre></td></tr></table></div>

<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/patterns/file-patters/javascript-plugin-file-pattern/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
