<?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>Information Technology Management &#38; Development &#187; programming</title>
	<atom:link href="http://blogs.yellowfish.biz/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.yellowfish.biz</link>
	<description>IT Consulting, Infrastructure, Software &#38; Voip Phone Systems</description>
	<lastBuildDate>Tue, 27 Jul 2010 20:04:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spring Unit Tests</title>
		<link>http://blogs.yellowfish.biz/2010/spring-unit-tests/</link>
		<comments>http://blogs.yellowfish.biz/2010/spring-unit-tests/#comments</comments>
		<pubDate>Wed, 26 May 2010 14:22:39 +0000</pubDate>
		<dc:creator>Praveen Ray</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[unit-test]]></category>

		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=353</guid>
		<description><![CDATA[Dependency Injection is supposed to make your life easier when it comes to writing Unit and Integration Tests; assuming you do your homework right and indeed make use of Injection. With Spring 3 annotations like @Autowired and configurations like , there really is no excuse for sloppiness.
Here&#8217;s is how to reap the rewards of DI [...]]]></description>
			<content:encoded><![CDATA[<p>Dependency Injection is supposed to make your life easier when it comes to writing Unit and Integration Tests; assuming you do your homework right and indeed make use of Injection. With Spring 3 annotations like @Autowired and configurations like <context:spring-configured/>, there really is no excuse for sloppiness.<br />
Here&#8217;s is how to reap the rewards of DI when writing unit tests. You can dependency inject each Test Class using same @Autowired annotation that you use for your normal classes.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.runner.RunWith</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.test.context.ContextConfiguration</span><span style="color: #339933;">;</span>
&nbsp;
@RunWith<span style="color: #009900;">&#40;</span>SpringJUnit4ClassRunner.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
@ContextConfiguration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;classpath:spring-config.xml&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyClassTest <span style="color: #009900;">&#123;</span>
   @Autowired
   <span style="color: #000000; font-weight: bold;">private</span> TransferMoneyStrategy strategy <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
   ....
   @Test
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> test_transfer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #666666; font-style: italic;">// write Asserts here</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Key is the annotation @ContextConfiguration &#8211; one line is all you need to boot up entire Spring infrastructure!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.yellowfish.biz/2010/spring-unit-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSV Parsing with Erlang</title>
		<link>http://blogs.yellowfish.biz/2009/csv-parsing-with-erlang/</link>
		<comments>http://blogs.yellowfish.biz/2009/csv-parsing-with-erlang/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 14:00:47 +0000</pubDate>
		<dc:creator>Praveen Ray</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=320</guid>
		<description><![CDATA[CVS Parsing code with Erlang using OTP gen_fsm]]></description>
			<content:encoded><![CDATA[<p>Since <a href="http://www.erlang.org/doc/">OTP</a> doesn&#39;t provide any CSV parsing capabilities, I decided to write my own based upon <a href="http://www.erlang.org/doc/man/gen_fsm.html">gen_fsm</a>. Following the short explanation given in Perl&#39;s <a href="http://search.cpan.org/~hmbrand/Text-CSV_XS-0.69/CSV_XS.pm#SPECIFICATION">Text::CSV_XS</a> module, I implemented a simple state machine. Erlang&#39;s excellent binary processing capabilities and built in gen_fsm behavior make the code compact, and surprisingly easy to implement. You can download the code from <a href="http://www.yellowfish.biz/code/parse_csv.erl">here</a>. A short explanation follows.</p>
<p>The state machine has only following handful of states:</p>
<h4>start_field</h4>
<p>Start reading a CSV field &#8211; it might be double quoted and might have special chars such as \r, \n, comma and double quote. Goto read_field or read_quoted_field, depending upon if a double quote started this field.</p>
<h4>read_field</h4>
<p>Once a field has started, we switch to this state and read binary bytes until and end of field condition is detected. End of Field is marked by either a comma or a newline.&nbsp;</p>
<h4>read_quoted_field</h4>
<p>We&#39;re inside a double quoted field; read everything until another double quote is encountered. A double quote might be end of this field or an embedded double quote marked with two consecutive double quotes. Switch to&nbsp;escaped_double_quote if a double quote is encountered.</p>
<h4>escaped_double_quote</h4>
<p>We come inside this field upon encountering a double quote inside read_quoted_field state. If another double quote is seen, it&#39;s an escaped double quote, else, it&#39;s nothing special. Both these cases go back to read_quoted_field.</p>
<h3>Usage</h3>
<p>Following public methods are exported:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">parse_csv<span style="color: #009900;">&#40;</span>File_path<span style="color: #009900;">&#41;</span>
parse_csv<span style="color: #009900;">&#40;</span>Binary_blob<span style="color: #009900;">&#41;</span>
parse_csv<span style="color: #009900;">&#40;</span>File_path<span style="color: #339933;">,</span> Options<span style="color: #009900;">&#41;</span>
parse_csv<span style="color: #009900;">&#40;</span>Binary_blob<span style="color: #339933;">,</span> Options<span style="color: #009900;">&#41;</span></pre></div></div>

<p>where Options is:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>callback_fn<span style="color: #339933;">,</span> Fun<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>callback_state<span style="color: #339933;">,</span> term<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span></pre></div></div>

<p>Fun is a function/2 and gets called with a List of Fields and callback state.</p>
<p>With no Options passed, the return is a list of list of Fields. With callback_fn passed, the Callback is called at the end of each line with a list of Fields.</p>
<h3>Examples:</h3>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">parse_csv<span style="color: #339933;">:</span>parse_csv<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;/tmp/data.csv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span></pre></div></div>

<p>Returns:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">&lt;&lt;</span><span style="color: #ff0000;">&quot;Date&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;Source&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;Destination&quot;</span><span style="color: #339933;">&gt;&gt;,</span>
  <span style="color: #339933;">&lt;&lt;</span><span style="color: #ff0000;">&quot;Seconds&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;CallerID&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;Disposition&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;Cost&quot;</span><span style="color: #339933;">&gt;&gt;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span><span style="color: #339933;">&lt;&lt;</span><span style="color: #ff0000;">&quot;2009-09-18 09:44:54&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;5097213333&quot;</span><span style="color: #339933;">&gt;&gt;,</span>
  <span style="color: #339933;">&lt;&lt;</span><span style="color: #ff0000;">&quot;18667778888&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;66&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;5098761323&quot;</span><span style="color: #339933;">&gt;&gt;,&lt;&lt;</span><span style="color: #ff0000;">&quot;ANSWERED&quot;</span><span style="color: #339933;">&gt;&gt;,</span>
  <span style="color: #339933;">&lt;&lt;</span><span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #339933;">&gt;&gt;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">F <span style="color: #339933;">=</span> fun<span style="color: #009900;">&#40;</span>Fields<span style="color: #339933;">,</span> State<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-&gt;</span> <span style="color: #006600;">io</span><span style="color: #339933;">:</span><span style="color: #000066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;~p~n&quot;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span>Fields<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> State <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> end<span style="color: #339933;">.</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">parse_csv<span style="color: #339933;">:</span>parse_csv<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;/tmp/data.csv&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>callback_fn<span style="color: #339933;">,</span> F<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>callback_state<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span></pre></div></div>

<div>It calls F repeatedly. First with second parameter set to 0, then 1, then2 and so on. Note that your fun must return a modified state which becomes second parameter to callback_fn for the next line.</div>
<div>&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.yellowfish.biz/2009/csv-parsing-with-erlang/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Injecting Traits into Javascript Objects</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/</link>
		<comments>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 17:01:24 +0000</pubDate>
		<dc:creator>Praveen Ray</dc:creator>
				<category><![CDATA[Web Applications / User Interface Design]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234</guid>
		<description><![CDATA[Duplication is the mother of all evil in programming. Remaining DRY at all costs should be your goal at all times. A pattern repeats itself one time and your code complexity goes up exponentially.
One great way to DRY up your code is via Traits. Traits are functional equivalent of base classes where you can collect [...]]]></description>
			<content:encoded><![CDATA[<p>Duplication is the mother of all evil in programming. Remaining DRY at all costs should be your goal at all times. A pattern repeats itself one time and your code complexity goes up exponentially.<br />
One great way to DRY up your code is via Traits. Traits are functional equivalent of base classes where you can collect most often used functions and inject these Traits into your objects. Here&#8217;s one simple way to do it in Javascript (using <a href="http://www.extjs.com">extjs</a> here):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">MyTrait <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
   xhr<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;">return</span> Ext.<span style="color: #660066;">Ajax</span>.<span style="color: #660066;">request</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   submit<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>basic_form<span style="color: #339933;">,</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #006600; font-style: italic;">//perform some checks on config </span>
               <span style="color: #006600; font-style: italic;">// and call basic_form.submit </span>
   <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #006600; font-style: italic;">//...add more utility functions</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> MyGrid<span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>MyGrid.<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: #339933;">,</span>config<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>MyGrid<span style="color: #339933;">,</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #339933;">,</span> MyTrait<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Clickable links within Extjs grid cells</title>
		<link>http://blogs.yellowfish.biz/2009/extjs-links-in-grid-cells/</link>
		<comments>http://blogs.yellowfish.biz/2009/extjs-links-in-grid-cells/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 13:57:05 +0000</pubDate>
		<dc:creator>Praveen Ray</dc:creator>
				<category><![CDATA[Computer Languages]]></category>
		<category><![CDATA[Web Applications / User Interface Design]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=224</guid>
		<description><![CDATA[An easy way to add clickable links to Extjs grid Cells.]]></description>
			<content:encoded><![CDATA[<p>Although the extjs <a href="http://www.extjs.com/deploy/dev/examples/samples.html#sample-2">grid</a> is an awesome component, IMO, it suffers from one major drawback &#8211; it&#8217;s inability to place active components within data cells. At least it&#8217;s not straightforward. Here&#8217;s a simple solution to place clickable links within cells. The trick is to place <span>s which look like links and then intercept rowclick and determine which of many links was clicked on.</p>
<p>Here&#8217;s an example of a custom Grid Component:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> MyComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   MyComponent.<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>
<span style="color: #009900;">&#125;</span>
Ext.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>MyComponent<span style="color: #339933;">,</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
MyComponent.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">initComponent</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: #003366; font-weight: bold;">var</span> action_tmpl <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">XTemplate</span><span style="color: #009900;">&#40;</span>
     <span style="color: #3366CC;">&quot;&lt;span class='link' id='edit-{id}'&gt;Edit&lt;/span&gt;&quot;</span><span style="color: #339933;">,</span>
     <span style="color: #3366CC;">&quot;&lt;span class='link' id='delete-{id}'&gt;Delete&lt;/span&gt;&quot;</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   action_tmpl.<span style="color: #660066;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #003366; font-weight: bold;">var</span> content <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// grid related config</span>
     columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #009900;">&#123;</span>header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'First Name'</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span><span style="color: #3366CC;">'fname'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#123;</span>header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Action'</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span><span style="color: #339933;">,</span> 
          renderer<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
              <span style="color: #000066; font-weight: bold;">return</span> action_tmpl.<span style="color: #660066;">applyTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span> id<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: #009900;">&#125;</span>
     <span style="color: #009900;">&#93;</span>
   <span style="color: #009900;">&#125;</span>
   MyComponent.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</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>content<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
MyComponent.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">afterRender</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>
  MyComponent.<span style="color: #660066;">superclass</span>.<span style="color: #660066;">afterRender</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>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rowclick'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">row_click</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: #009900;">&#125;</span>
&nbsp;
MyComponent.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">row_click</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>grid<span style="color: #339933;">,</span> ri<span style="color: #339933;">,</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> rec <span style="color: #339933;">=</span> grid.<span style="color: #660066;">getStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getAt</span><span style="color: #009900;">&#40;</span>ri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #006600; font-style: italic;">// See Below for within_el method</span>
   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>evt.<span style="color: #660066;">within_el</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'edit-'</span><span style="color: #339933;">+</span>r.<span style="color: #660066;">id</span><span style="color: #009900;">&#41;</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;">'Edit clicked'</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;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>evt.<span style="color: #660066;">within_el</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'delete-'</span><span style="color: #339933;">+</span>r.<span style="color: #660066;">id</span><span style="color: #009900;">&#41;</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;">'Delete clicked'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p> The within_el method on Ext.EventObject object looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">EventObject</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    within_el<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        el <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span>el<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: #339933;">!</span>el<span style="color: #009900;">&#41;</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: #003366; font-weight: bold;">var</span> evt_xy <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getXY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> evt_x <span style="color: #339933;">=</span> evt_xy<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> evt_y <span style="color: #339933;">=</span> evt_xy<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>evt_x <span style="color: #339933;">&gt;</span> el.<span style="color: #660066;">getLeft</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> evt_x <span style="color: #339933;">&lt;</span> el.<span style="color: #660066;">getRight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> evt_y <span style="color: #339933;">&gt;</span> el.<span style="color: #660066;">getTop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> evt_y <span style="color: #339933;">&lt;</span> el.<span style="color: #660066;">getBottom</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blogs.yellowfish.biz/2009/extjs-links-in-grid-cells/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ExtJS : Our favorite Javascript Ajax Library</title>
		<link>http://blogs.yellowfish.biz/2009/extjs-our-favorite-javascript-ajax-library/</link>
		<comments>http://blogs.yellowfish.biz/2009/extjs-our-favorite-javascript-ajax-library/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 15:17:36 +0000</pubDate>
		<dc:creator>Praveen Ray</dc:creator>
				<category><![CDATA[Web Frameworks]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[license]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=42</guid>
		<description><![CDATA[There are number of ajax javascript libraries and frameworkds out there and it can be excruciating to try and find the best fit your projects and organization. A good library should encapsulate most often used patterns and provide clear and easy to use abstractions. No library, however mature, can be complete, since it&#8217;s always possible [...]]]></description>
			<content:encoded><![CDATA[<p>There are number of ajax javascript libraries and frameworkds out there and it can be excruciating to try and find the best fit your projects and organization. A good library should encapsulate most often used patterns and provide clear and easy to use abstractions. No library, however mature, can be complete, since it&#8217;s always possible to find that one most important piece of missing functionality that you need. So, extensionability is a major requirement.</p>
<p>Javascript is an awesome language. It&#8217;s super flexible. It empowers the developer with immense flexibility. You can use the power to advance world peace or choose to shoot yourself. It&#8217;s totally upto you. As spiderman said &#8211; with power comes responsibility. Since there are no private namespaces in Javascript, it&#8217;s ultra important that the library you choose NEVER dirties your namespace and lives completely inside it&#8217;s own namespace. One of the most popular javascript library &#8211; prototype.js &#8211; violates this principle completely and IMHO, should be used with care.</p>
<p>Javascript started in Browsers and even today it&#8217;s most often found in the browsers. Browsers are the modern UI paradigm. The javascript library must not be limited to cookie-cutter DOM manipulation APIs. That was cool in the 90s. The Libraries now must provide a rich set of UI Widgets. You don&#8217;t want to be using two Javascript libraries &#8211; one for Ajax and other for UI widgets.</p>
<p>Documentation. If the developer has to resort to &#8216;grep&#8217; the source code to find essential pieces of functionality, the library becomes a time hog instead of rapid development platform!</p>
<p>We looked at quite a few js libraries :</p>
<p>    * JQuery<br />
    * Qooxdoo<br />
    * Dojo<br />
    * Prototype.js<br />
    * mootools<br />
    * extjs</p>
<p>and settled for extjs as our framework of choice.</p>
<p>Here are our reasons for picking a commercial open source library like extjs.<br />
The overall design of extjs is exemplary. One can learn a lot from it&#8217;s unified architecture &#8211; no matter which language one is programming in.</p>
<p>It lives within it&#8217;s own namespace. Prototype.js was out at this point.</p>
<p>The UI widget set is extremely rich. Dojo, qooxdoo and mootools &#8211; although promising, were nowhere close to extjs in widgets collection. Although jquery , with it&#8217;s collection of opensource plugins, has a rich collection, it suffers from one major disadvantage. The plugins are from multiple vendors and there is no consistent Object model to dictate their design. Extjs requires you to start with one of their base classes &#8211; ensuring a consitent model. Consistency is extremely important for the library to be reusable.</p>
<p>Not to mention, extjs documentation seems to be very comprehensive and well maintained. In a library as comprehensive as extjs, one should always be prepared to look into the source code to fund missing bits but all essential pieces are very well documented.</p>
<p>Many people seem to object to commercial licencing of extjs &#8211; however, we believe, the licencing is quite fair and inexpensive. A single developer licence costs less than $300 and one can deploy on unlimited domains. You can develop your application for free and purchase a licence when you go live. For most businesses this shouldn&#8217;t be an issue at all.<br />
On the other hand, if your business can&#8217;t come up with $300.00, you&#8217;ve bigger issues and shouldn&#8217;t be worried about javascript libraries !!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.yellowfish.biz/2009/extjs-our-favorite-javascript-ajax-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
