<?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>Blog de desenvolvimento da Milfont Consulting, Client e Server-side &#187; ECMAScript</title>
	<atom:link href="http://www.milfont.org/tech/tag/ecmascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.milfont.org/tech</link>
	<description>Blog da Comunidade Milfont Consulting, uma empresa especializada em desenvolvimento Web, principalmente Javascript, node.js e muito Javascript.</description>
	<lastBuildDate>Thu, 26 Jan 2012 11:30:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Compatibilidade dos navegadores com especificação javascript ECMA 262</title>
		<link>http://www.milfont.org/tech/2011/04/29/compatibilidade-dos-navegadores-com-especificacao-javascript-ecma-262/</link>
		<comments>http://www.milfont.org/tech/2011/04/29/compatibilidade-dos-navegadores-com-especificacao-javascript-ecma-262/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 14:01:23 +0000</pubDate>
		<dc:creator>cmilfont</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ECMAScript]]></category>

		<guid isPermaLink="false">http://www.milfont.org/tech/?p=1243</guid>
		<description><![CDATA[Fiz um teste nesse momento em 4 navegadores que utilizo no dia-a-dia usando o projeto Sputnik do GoogleLabs para saber a aderencia à especificação ECMA 262. Fiz um teste sem compromisso e sem rigor acadêmico, apenas por curiosidade. Esse teste é interessante para sabermos que possíveis problemas irão acontecer por diferença de implementação do Javascript [...]]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:left;"><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript">
			<!-- 
				tweetmeme_url = "http://www.milfont.org/tech/2011/04/29/compatibilidade-dos-navegadores-com-especificacao-javascript-ecma-262/";
				tweetmeme_source = "tweetmeme";
				tweetmeme_style = "";
				
			//-->
			</script>
                        <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div></div><p>Fiz um teste nesse momento em 4 navegadores que utilizo no dia-a-dia usando o projeto <a href="http://sputnik.googlelabs.com">Sputnik</a> do GoogleLabs para saber a aderencia à especificação <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA 262</a>. Fiz um teste sem compromisso e sem rigor acadêmico, apenas por curiosidade.</p>
<p>Esse teste é interessante para sabermos que possíveis problemas irão acontecer por diferença de implementação do Javascript por cada engine.</p>
<h2>Firefox</h2>
<table id="stats" style="height: 56px;" width="169">
<tbody>
<tr>
<td>Total:</td>
<td id="total">5246</td>
</tr>
<tr>
<td>Succeeded:</td>
<td id="succeeded">4982</td>
</tr>
<tr>
<td>Failed:</td>
<td id="failed">264</td>
</tr>
</tbody>
</table>
<p>Versão 3.6.16</p>
<h2>Opera</h2>
<table id="stats" style="height: 56px;" width="169">
<tbody>
<tr>
<td>Total:</td>
<td id="total">5246</td>
</tr>
<tr>
<td>Succeeded:</td>
<td id="succeeded">5172</td>
</tr>
<tr>
<td>Failed:</td>
<td id="failed">74</td>
</tr>
</tbody>
</table>
<p>Versão 11.01 &#8211; Build 1190</p>
<h2>Chrome</h2>
<table id="stats" style="height: 56px;" width="169">
<tbody>
<tr>
<td>Total:</td>
<td id="total">5246</td>
</tr>
<tr>
<td>Succeeded:</td>
<td id="succeeded">5110</td>
</tr>
<tr>
<td>Failed:</td>
<td id="failed">136</td>
</tr>
</tbody>
</table>
<p>Versão 11.0.696.57</p>
<h2>Safari</h2>
<table id="stats" style="height: 56px;" width="169">
<tbody>
<tr>
<td>Total:</td>
<td id="total">5246</td>
</tr>
<tr>
<td>Succeeded:</td>
<td id="succeeded">5083</td>
</tr>
<tr>
<td>Failed:</td>
<td id="failed">163</td>
</tr>
</tbody>
</table>
<p>Versão 5.0.5 (6533.21.1)</p>
<h2>Voltei&#8230;</h2>
<p>O interessante é observar que o Opera é o mais aderente, o Firefox o mais lento [travou], o Chrome o mais rápido. Para não ser injusto com o Firefox, eu ainda matei o processo, abre uma instância novinha e mesmo assim ele travou na execução, abriu aquela janelinha marota pedindo para encerrar o script.</p>
<div class="wp-caption alignnone" style="width: 410px"><a href="http://www.milfont.org/tech/wp-content/upload/chrome.png"><img title="teste" src="http://www.milfont.org/tech/wp-content/upload/chrome.png" alt="" width="400" height="200" /></a><p class="wp-caption-text">Sequencia no sentido horário: Opera, Firefox, Safari e Chrome.</p></div>
<p>A velocidade e economia do Chrome é realmente impressionante, observe os processos:</p>
<div class="wp-caption alignnone" style="width: 410px"><a href="http://www.milfont.org/tech/wp-content/upload/processos.png"><img title="processos" src="http://www.milfont.org/tech/wp-content/upload/processos.png" alt="" width="400" height="200" /></a><p class="wp-caption-text">Sequencia no sentido horário: Opera, Firefox, Safari e Chrome.</p></div>
<p>Dados da minha máquina:</p>
<p><a href="http://www.milfont.org/tech/wp-content/upload/mac.png"><img title="mac" src="http://www.milfont.org/tech/wp-content/upload/mac.png" alt="" width="331" height="337" /></a></p>
<h2>[update]</h2>
<p>Como eu sei que alguém vai me acusar de parcial, etc e tal, eu resolvi abrir uma VM aqui com XP e IE8 para não dizerem que não falei de flores &#8230; olha só:</p>
<p><a href="http://www.milfont.org/tech/wp-content/upload/win-ie.png"><img class="alignnone" title="WinXp com IE8" src="http://www.milfont.org/tech/wp-content/upload/win-ie.png" alt="" width="400" height="300" /></a></p>
<p>Ok, é má vontade&#8230; Sério?</p>
<p><a href="http://www.milfont.org/tech/wp-content/upload/ietravou.png"><img class="alignnone" title="IE8 Travou" src="http://www.milfont.org/tech/wp-content/upload/ietravou.png" alt="" width="400" height="300" /></a></p>
<p>Uns 10 minutos depois e sem voltar [continua travado], já basta esses dados para mostrar que o IE8 é uma bo$ta em relação a aderência [imagina o 6]:</p>
<p><a href="http://www.milfont.org/tech/wp-content/upload/valeapena.png"><img class="alignnone" title="Isso vale a pena?" src="http://www.milfont.org/tech/wp-content/upload/valeapena.png" alt="" width="400" height="65" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.milfont.org/tech/2011/04/29/compatibilidade-dos-navegadores-com-especificacao-javascript-ecma-262/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introdução ao Ext</title>
		<link>http://www.milfont.org/tech/2009/06/29/introducao-ao-ext/</link>
		<comments>http://www.milfont.org/tech/2009/06/29/introducao-ao-ext/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 13:38:32 +0000</pubDate>
		<dc:creator>cmilfont</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Ext]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[web2.0]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>
		<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Orientação a Objetos]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.milfont.org/tech/?p=24</guid>
		<description><![CDATA[Eu trabalho com Extjs desde que ele era uma extensão para o YUI, ainda hoje há aplicação no ar usando essa antiga tecnologia [por problema causado por algum idiota, você provavelmente será redirecionado para outro site do governo, dá uma olhada no canto esquerdo superior e clique em "IR PARA A SEPLAG"]. Para ver o [...]]]></description>
			<content:encoded><![CDATA[<p>Eu trabalho com <a href="http://www.extjs.com/products/extjs/">Extjs</a> desde que ele era uma extensão para o <a href="http://developer.yahoo.com/yui/">YUI</a>, ainda hoje <a href="http://www.seplag.ce.gov.br/seplag/categoria2/diario-oficial">há aplicação no ar</a> usando essa antiga tecnologia [por problema <a href="http://www.milfont.org/tech/2009/03/25/como-simular-trabalho-no-estado/">causado por algum idiota</a>, você provavelmente será redirecionado para outro site do governo, dá uma olhada no canto esquerdo superior e clique em "<strong>IR PARA A SEPLAG</strong>"]. Para ver o Extjs no tempo que ele se chamava ext-yui, vá no link de pesquisa avançada, preencha o input descrição em &#8220;dados da matéria&#8221; com &#8220;secretaria de cultura&#8221; por exemplo e clique no botão pesquisar.</p>
<p>Esse tutorial tem o objetivo de preparar o conhecimento para outros posts que estou escrevendo e achei necessário uma introdução apenas nos conceitos do Extjs para não confundir com as tecnologias que uso em conjunto como <a href="http://www.milfont.org/tech/tag/dwr/">DWR</a> ou no modelo <a href="http://www.milfont.org/tech/tag/rest/">REST</a> com o <a href="http://www.milfont.org/tech/tag/rails/">RubyOnRails</a>.</p>
<p>O Extjs é um <a href="http://www.milfont.org/tech/2007/10/11/frameworks-ajax/">framework javascript de propósito geral</a>, ou seja, tem um conjunto de funcionalidades que tratam <a href="http://www.milfont.org/tech/tag/ajax/">Ajax</a>, um conjunto de Widgets bem elaborados [componentes visuais como Grid e TabPanel], manipulação de DOM [Document Object Model] e BOM [Browser Object Model], tratamento de eventos, animações como Fade In e Fade Out, parser de <a href="http://www.milfont.org/tech/2007/11/04/o-que-e-json/">JSON</a>, entre outras coisas. Seus componentes são construídos com técnicas modernas de<a href="http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/"> orientação</a> a <a href="http://www.milfont.org/tech/2007/10/01/overloading-e-overriding-no-javascript/">objetos</a> no javascript e manipulação de <a href="http://www.milfont.org/tech/2007/10/08/script-tag/">Scripttag</a> para recursos remotos que não suportam Ajax.</p>
<h2>Preparação</h2>
<p>Após <a href="http://www.extjs.com/products/extjs/download.php">baixar e descompactar</a> o framework [estou trabalhando na versão 2.x que é estável nessa data], recomendo que deixa a disposição das pastas conforme se encontra e coloque no seu projeto de forma que seja acessível via web, já vem com documentação e exemplos que você deve e vai usar durante o desenvolvimento. Temos a <a href="http://www.extjs.com/products/extjs/build/">opção de montar o Extjs</a> [marcando a opção "<em>Make build available via CacheFly</em>" ] no <a href="http://cachefly.com/">CacheFly</a> como um servidor <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network">CDN</a> para <a href="http://www.milfont.org/tech/2007/10/10/otimizando-wordpress-com-yslow/">otimizar o tráfego</a> de sua aplicação principalmente se ela será disponibilizada na internet e não apenas na intranet.</p>
<p>É necessário importar o CSS global, o adapter e o Javascript global conforme mostrado abaixo:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/javascripts/ext-2.2.1/resources/css/ext-all.css&quot; /&gt;
&lt;script src=&quot;/javascripts/ext-2.2.1/adapter/ext/ext-base.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/javascripts/ext-2.2.1/ext-all.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>Pode usar outros temas para o Extjs, estarão na pasta &#8220;<em>resources/css</em>&#8220;, assim como podemos internacionalizar os componentes com arquivos que se encontram em &#8220;<em>build/locale</em>&#8220;. Exemplo com o tema &#8220;Gray&#8221; e <a href="http://en.wikipedia.org/wiki/Internationalization_and_localization">i18n</a> em português do Brasil:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/javascripts/ext-2.2.1/resources/css/ext-all.css&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/javascripts/ext-2.2.1/resources/css/xtheme-gray.css&quot;&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/ext-2.2.1/adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/ext-2.2.1/ext-all.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/ext-2.2.1/build/locale/ext-lang-pt_BR-min.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>Internacionalização é algo pensado no Extjs de forma a facilitar a criação de arquivos de linguagem aproveitando a estrutura da linguagem [dinâmica e fracamente tipada], todas as propriedades de mensagens e textos são públicas para facilitar a reescrita como mostrado abaixo na i18n do componente de DataPicker:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">DatePicker</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>Ext.<span style="color: #660066;">DatePicker</span>.<span style="color: #660066;">prototype</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
      todayText         <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Hoje&quot;</span><span style="color: #339933;">,</span>
      minText           <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Esta data &amp;eacute; anterior a menor data&quot;</span><span style="color: #339933;">,</span>
      maxText           <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Esta data &amp;eacute; posterior a maior data&quot;</span><span style="color: #339933;">,</span>
      disabledDaysText  <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
      disabledDatesText <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
      monthNames        <span style="color: #339933;">:</span> Date.<span style="color: #660066;">monthNames</span><span style="color: #339933;">,</span>
      dayNames          <span style="color: #339933;">:</span> Date.<span style="color: #660066;">dayNames</span><span style="color: #339933;">,</span>
      nextText          <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Pr&amp;oacute;ximo M&amp;ecirc;s (Control+Direita)'</span><span style="color: #339933;">,</span>
      prevText          <span style="color: #339933;">:</span> <span style="color: #3366CC;">'M&amp;ecirc;s Anterior (Control+Esquerda)'</span><span style="color: #339933;">,</span>
      monthYearText     <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Escolha um M&amp;ecirc;s (Control+Cima/Baixo para mover entre os anos)'</span><span style="color: #339933;">,</span>
      todayTip          <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;{0} (Espa&amp;ccedil;o)&quot;</span><span style="color: #339933;">,</span>
      format            <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;d/m/Y&quot;</span><span style="color: #339933;">,</span>
      okText            <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&amp;#160;OK&amp;#160;&quot;</span><span style="color: #339933;">,</span>
      cancelText        <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Cancelar&quot;</span><span style="color: #339933;">,</span>
      startDay          <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Se você usar o CacheFly gerado pela página do Extjs, ele incluir o adapter e o global em um mesmo arquivo, vai ser algo como:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://extjs.cachefly.net/ext-2.2.1/resources/css/xtheme-gray.css&quot;&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://extjs.cachefly.net/builds/ext-cdn-771.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<h2>Adapter</h2>
<p>Quando o Extjs passou a ser um framework independente do YUI, passou a adotar outros frameworks como base para funções básicas de manipulação de DOM e Ajax, hoje suporta trabalhar em conjunto com YUI, JQuery, Prototype e totalmente independente. Se o projeto já tem Jquery ou outro framework que trabalha com o Extjs, a utilização dos dois é muito fácil e indicada, principalmente para usar os widgets que são provavelmente os mais poderosos hoje em dia em um framework opensource.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">//Exemplos de adapters permitidos
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/ext-2.2.1/adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/javascripts/ext-2.2.1/adapter/jquery/ext-jquery-adapter.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<h2>Widgets</h2>
<p>O principal apelo do Extjs que conquista os desenvolvedores é o layout bem trabalhado dos componentes visuais que são de fácil parametrização. Basicamente todos os componentes funcionam da mesma forma, você o instancia passando um <a href="http://www.milfont.org/tech/2007/11/04/o-que-e-json/">objeto literal</a> de configuração com mostrado abaixo:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//Exemplo do grid</span>
<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;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
autoShow<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;">750</span><span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">250</span> <span style="color: #006600; font-style: italic;">//mais parametros </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;">//Exemplo de uma Window</span>
<span style="color: #003366; font-weight: bold;">var</span> window <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>
autoShow<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;">750</span><span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">250</span> <span style="color: #006600; font-style: italic;">//mais parametros </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;">//Exemplo de um Painel</span>
<span style="color: #003366; font-weight: bold;">var</span> panel <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>
autoShow<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;">750</span><span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">250</span> <span style="color: #006600; font-style: italic;">//mais parametros </span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Vamos usar o GRID para exemplificar como trabalhamos com o Extjs, o mesmo comportamente se repete em todos os componentes.<br />
A <a href="http://www.extjs.com/deploy/dev/docs/">documentação do Extjs</a> é muito bem feita e praticamente vai ser a única coisa que você vai precisar depois de entender como os componentes são formados, afinal não vale a pena decorar todas as propriedades de todos os componentes, concentre-se apenas em entender os conceitos.</p>
<p>A GRID é o Widget mais famoso desse framework e é formado basicamente por um objeto &#8220;<strong>Ext.data.Store</strong>&#8221; [que é a fonte de dados da GRID] e um objeto &#8220;<strong>Ext.grid.ColumnModel</strong>&#8221; [que é a definição das colunas], como mostrado abaixo:</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;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    autoShow<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;">750</span><span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">250</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//parametros de configuração de layout</span>
    cm<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;">ColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/*configuração*/</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</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><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//Ou especialização de um Store</span>
    sm<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;">RowSelectionModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>singleSelect<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> <span style="color: #006600; font-style: italic;">//ou outra especialização de um AbstractSelectionModel</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>O objeto ColumnModel é a definição de colunas do Grid, possui propriedades para definição de layout como largura e altura, título da coluna como vai ser exibida e formatação do texto:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> colModel <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;">ColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>
    <span style="color: #009900;">&#123;</span> header<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Ticker&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">60</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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;">&quot;Company Name&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">150</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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;">&quot;Market Cap.&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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;">&quot;$ Sales&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> renderer<span style="color: #339933;">:</span> money<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;">&quot;Employees&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> resizable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</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>

<p>A propriedade cm [ColumnModel] pode ser também substituída pela propriedade &#8220;columns&#8221; que funciona como um &#8220;alias&#8221;, dessa forma o Grid cria automaticamente um objeto ColumnModel:</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;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span><span style="color: #339933;">,</span> header<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'id'</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;">&quot;Nome&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">120</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</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></pre></div></div>

<p>Caso haja necessidade de formatar o conteúdo da célula, você pode usar uma função como &#8220;renderer&#8221; para tratar esse conteúdo:</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;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span><span style="color: #339933;">,</span> header<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'id'</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;">&quot;Nome&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">120</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</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;">&quot;Criado em&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">135</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> Date.<span style="color: #660066;">parseDate</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">,</span> <span style="color: #3366CC;">'Y-m-d<span style="color: #000099; font-weight: bold;">\\</span>TH:i:s<span style="color: #000099; font-weight: bold;">\\</span>Z'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'d/m/Y H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #006600; font-style: italic;">//2009-06-14T12:51:07Z</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'created_at'</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></pre></div></div>

<p>A propriedade &#8220;<strong>store</strong>&#8221; da GRID é uma especialização do componente &#8220;<strong>Ext.data.Store</strong>&#8221; que é formado basicamente por um &#8220;<strong>proxy</strong>&#8221; e um &#8220;<strong>reader</strong>&#8220;:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</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>
    proxy<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;">DataProxy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//ou uma especialização</span>
    reader<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;">DataReader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">//ou uma especialização</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>O &#8220;<strong>proxy</strong>&#8221; é o componente que obterá os dados e o &#8220;<strong>reader</strong>&#8221; o componente que fará a leitura desses dados para um formato comum a todos os componentes do Extjs na forma de um objeto denominado &#8220;<strong>Ext.data.Record</strong>&#8220;. O objeto &#8220;Record&#8221; representa um registro de dados e é usado seja para GRID, para um Form ou qualquer componente que trabalhe com dados editáveis.</p>
<p>Dessa forma podemos usar uma combinação de Proxy e Reader como HttpProxy e JsonReader:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</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>
    proxy<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;">HttpProxy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'projects.json'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    reader<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;">JsonReader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        totalProperty<span style="color: #339933;">:</span><span style="color: #3366CC;">'total'</span><span style="color: #339933;">,</span>
        root<span style="color: #339933;">:</span><span style="color: #3366CC;">'results'</span><span style="color: #339933;">,</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Record</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</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;">'name'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'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;">'created_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'created_at'</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;">'updated_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'updated_at'</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</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>Devido o costume do uso do HttpProxy, o componente Store possui uma propriedade chamada &#8220;url&#8221; que estando presente cria um HttpProxy automaticamente como mostrado abaixo:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</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>
    url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'projects.json'</span><span style="color: #339933;">,</span>
    reader<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;">JsonReader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        totalProperty<span style="color: #339933;">:</span><span style="color: #3366CC;">'total'</span><span style="color: #339933;">,</span>
        root<span style="color: #339933;">:</span><span style="color: #3366CC;">'results'</span><span style="color: #339933;">,</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Record</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</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;">'name'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'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;">'created_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'created_at'</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;">'updated_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'updated_at'</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</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>O objeto &#8220;<strong>Reader</strong>&#8221; é o único que foge um pouco a regra de instanciação por receber dois parâmetros, um similar aos outros com um objeto literal de configuração e outro com o mapeamento dos dados. O objeto de configuração tem duas propriedades de que representam o total e a lista de dados. O objeto de mapeamento usa um método &#8220;estático&#8221; do objeto Record para criar um link entre a propriedade do json [com a propriedade "mapping"] e o índice interno do Record [pela propriedade "name"].</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">JsonReader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        totalProperty<span style="color: #339933;">:</span><span style="color: #3366CC;">'total'</span><span style="color: #339933;">,</span>
        root<span style="color: #339933;">:</span><span style="color: #3366CC;">'results'</span><span style="color: #339933;">,</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Record</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</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;">'name'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'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;">'created_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'created_at'</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;">'updated_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'updated_at'</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Dessa forma você tem um link entre o ColumnName pela propriedade dataIndex e o Store por meio do Reader, como abaixo:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Record</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</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;">'nome_linkado'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'name'</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #006600; font-style: italic;">//</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;">&quot;Nome&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">120</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'nome_linkado'</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span></pre></div></div>

<p>Para melhorar a navegação da GRID, você pode também acrescentar um componente de Toolbar no header ou no footer:</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;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    autoShow<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;">750</span><span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">250</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//parametros de configuração de layout</span>
    cm<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;">ColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">/*configuração*/</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</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><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//Ou especialização de um Store</span>
    sm<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;">RowSelectionModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>singleSelect<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>
    bbar<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Toolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//Bottom Toolbar</span>
    tbar<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Toolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">//Top Toolbar</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A Toolbar mais usada é sua especialização com paginação, a Ext.PagingToolbar que necessita ser linkada com o Store:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">PagingToolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    pageSize<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//propriedade opcional, default é 20</span>
    store<span style="color: #339933;">:</span> store
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>A PagingToolbar é I18n, mas se as mensagens não agradarem você pode mudá-las [eu sempre faço]:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">PagingToolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    pageSize<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
    displayInfo<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>	
    displayMsg<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Exibindo o resultado: {0} a {1} de {2} registros'</span><span style="color: #339933;">,</span>
    emptyMsg<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Sem resultados a exibir&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Uma coisa bacana nesse componente é que você pode agrupar botões [já que é uma Toolbar] e até padronizar o layout:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">PagingToolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    pageSize<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
    displayInfo<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>	
    displayMsg<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Exibindo o resultado: {0} a {1} de {2} registros'</span><span style="color: #339933;">,</span>
    emptyMsg<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Sem resultados a exibir&quot;</span><span style="color: #339933;">,</span>
    items<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'-'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        pressed<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>enableToggle<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>text<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Alterar'</span><span style="color: #339933;">,</span>
        toggleHandler<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: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        pressed<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>enableToggle<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>text<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Excluir'</span><span style="color: #339933;">,</span>
        toggleHandler<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: #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;">&#41;</span></pre></div></div>

<p>Código da GRID inteira:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">var</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>
    proxy<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;">HttpProxy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'projects.json'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    reader<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;">JsonReader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        totalProperty<span style="color: #339933;">:</span><span style="color: #3366CC;">'total'</span><span style="color: #339933;">,</span>
        root<span style="color: #339933;">:</span><span style="color: #3366CC;">'results'</span><span style="color: #339933;">,</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Record</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</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;">'id'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</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;">'name'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'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;">'created_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'created_at'</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;">'updated_at'</span><span style="color: #339933;">,</span> mapping<span style="color: #339933;">:</span><span style="color: #3366CC;">'updated_at'</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</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: #003366; font-weight: bold;">var</span> colModel <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;">ColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>
    <span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">'id'</span><span style="color: #339933;">,</span> header<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'id'</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;">&quot;Nome&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">120</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</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;">&quot;Criado em&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">135</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">return</span> Date.<span style="color: #660066;">parseDate</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">,</span> <span style="color: #3366CC;">'Y-m-d<span style="color: #000099; font-weight: bold;">\\</span>TH:i:s<span style="color: #000099; font-weight: bold;">\\</span>Z'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'d/m/Y H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'created_at'</span><span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> pagingToolbar <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">PagingToolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    pageSize<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
    displayInfo<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>	
    displayMsg<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Exibindo o resultado: {0} a {1} de {2} registros'</span><span style="color: #339933;">,</span>
    emptyMsg<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Sem resultados a exibir&quot;</span><span style="color: #339933;">,</span>
    items<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'-'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        pressed<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>enableToggle<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>text<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Alterar'</span><span style="color: #339933;">,</span>
        toggleHandler<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: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        pressed<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>enableToggle<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>text<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Excluir'</span><span style="color: #339933;">,</span>
        toggleHandler<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: #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;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<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;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    autoShow<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;">750</span><span style="color: #339933;">,</span>height<span style="color: #339933;">:</span><span style="color: #CC0000;">250</span><span style="color: #339933;">,</span>
    cm<span style="color: #339933;">:</span> colModel<span style="color: #339933;">,</span>
    store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
    sm<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;">RowSelectionModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>singleSelect<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>
    bbar<span style="color: #339933;">:</span> pagingToolbar
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Como eu falei, todos os componentes possuem o mesmo comportamento, notaram que dá para aproveitar esse código semelhante e reaproveitar em todos os CRUDs?<br />
Vou falando de um por um de acordo com os posts que forem saindo, aguardem que o próximo sai logo&#8230; ou não.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.milfont.org/tech/2009/06/29/introducao-ao-ext/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Resumo javascript &#8211; Jan 2008</title>
		<link>http://www.milfont.org/tech/2008/01/31/resumo-javascript-jan-2008/</link>
		<comments>http://www.milfont.org/tech/2008/01/31/resumo-javascript-jan-2008/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 18:30:53 +0000</pubDate>
		<dc:creator>cmilfont</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ECMAScript]]></category>

		<guid isPermaLink="false">http://www.milfont.org/tech/2008/01/31/resumo-javascript-jan-2008/</guid>
		<description><![CDATA[Tudo que escrevi de relevante sobre javascript aqui, detalhe para o excelente tutorial no último link. http://www.milfont.org/tech/2007/10/01/overloading-e-overriding-no-javascript/ http://www.milfont.org/tech/2007/10/01/desreferenciando-objetos/ http://www.milfont.org/tech/2007/10/01/early-vs-late-binding/ http://www.milfont.org/tech/2007/10/02/eval-is-evil/ http://www.milfont.org/tech/2007/10/03/destilando-o-xmlhttprequest/ http://www.milfont.org/tech/2007/10/04/deteccao-otimizada-com-javascript/ http://www.milfont.org/tech/2007/10/05/bridge-para-encapsular-o-cross-browser/ http://www.milfont.org/tech/2007/10/08/script-tag/ http://www.milfont.org/tech/2007/10/11/frameworks-ajax/ http://www.milfont.org/tech/2007/10/13/funcao-dollar-do-prototype-para-capturar-elementos-html/ http://www.milfont.org/tech/2007/10/15/page-transitions-no-internet-explorer/ http://www.milfont.org/tech/2007/10/28/material-do-curso-de-ajax-triadworks/ http://www.milfont.org/tech/2007/10/29/material-da-minha-primeira-palestra-sobre-ajax/ http://www.milfont.org/tech/2007/11/04/o-que-e-json/ http://www.milfont.org/tech/2008/01/04/jsonrequest-para-evitar-o-eval/ http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/ http://www.milfont.org/tech/2008/01/07/quando-o-ie-trabalha-corretamente/ http://www.milfont.org/tech/2008/01/22/tutoriais-de-javascript/]]></description>
			<content:encoded><![CDATA[<p>Tudo que escrevi de relevante sobre javascript aqui, detalhe para o excelente tutorial no último link.</p>
<ul>
<li> <a href="http://www.milfont.org/tech/2007/10/01/overloading-e-overriding-no-javascript/">http://www.milfont.org/tech/2007/10/01/overloading-e-overriding-no-javascript/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/01/desreferenciando-objetos/">http://www.milfont.org/tech/2007/10/01/desreferenciando-objetos/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/01/early-vs-late-binding/">http://www.milfont.org/tech/2007/10/01/early-vs-late-binding/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/02/eval-is-evil/">http://www.milfont.org/tech/2007/10/02/eval-is-evil/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/03/destilando-o-xmlhttprequest/">http://www.milfont.org/tech/2007/10/03/destilando-o-xmlhttprequest/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/04/deteccao-otimizada-com-javascript/">http://www.milfont.org/tech/2007/10/04/deteccao-otimizada-com-javascript/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/05/bridge-para-encapsular-o-cross-browser/">http://www.milfont.org/tech/2007/10/05/bridge-para-encapsular-o-cross-browser/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/08/script-tag/">http://www.milfont.org/tech/2007/10/08/script-tag/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/11/frameworks-ajax/">http://www.milfont.org/tech/2007/10/11/frameworks-ajax/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/13/funcao-dollar-do-prototype-para-capturar-elementos-html/">http://www.milfont.org/tech/2007/10/13/funcao-dollar-do-prototype-para-capturar-elementos-html/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/15/page-transitions-no-internet-explorer/">http://www.milfont.org/tech/2007/10/15/page-transitions-no-internet-explorer/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/28/material-do-curso-de-ajax-triadworks/">http://www.milfont.org/tech/2007/10/28/material-do-curso-de-ajax-triadworks/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/10/29/material-da-minha-primeira-palestra-sobre-ajax/">http://www.milfont.org/tech/2007/10/29/material-da-minha-primeira-palestra-sobre-ajax/</a></li>
<li> <a href="http://www.milfont.org/tech/2007/11/04/o-que-e-json/">http://www.milfont.org/tech/2007/11/04/o-que-e-json/</a></li>
<li> <a href="http://www.milfont.org/tech/2008/01/04/jsonrequest-para-evitar-o-eval/">http://www.milfont.org/tech/2008/01/04/jsonrequest-para-evitar-o-eval/</a></li>
<li> <a href="http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/">http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/</a></li>
<li> <a href="http://www.milfont.org/tech/2008/01/07/quando-o-ie-trabalha-corretamente/">http://www.milfont.org/tech/2008/01/07/quando-o-ie-trabalha-corretamente/</a></li>
<li> <a href="http://www.milfont.org/tech/2008/01/22/tutoriais-de-javascript/">http://www.milfont.org/tech/2008/01/22/tutoriais-de-javascript/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.milfont.org/tech/2008/01/31/resumo-javascript-jan-2008/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Herança no Javascript</title>
		<link>http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/</link>
		<comments>http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 20:14:51 +0000</pubDate>
		<dc:creator>cmilfont</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Linguagens]]></category>
		<category><![CDATA[Orientação a Objetos]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[herança]]></category>
		<category><![CDATA[Nicholas C. Zakas]]></category>

		<guid isPermaLink="false">http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/</guid>
		<description><![CDATA[Herança é capacidade de um objeto reusar (herdar) os métodos e propriedades de outro objeto. O modelo de orientação a objetos baseado em protótipos, estabelece que um objeto serve de &#8220;molde&#8221; ou &#8220;base&#8221; (protótipo) para outro e a herança em javascript adiciona a propriedade global &#8220;instanceof&#8221; para definir se um objeto &#8220;é&#8221; do mesmo tipo [...]]]></description>
			<content:encoded><![CDATA[<p>Herança é capacidade de um objeto reusar (herdar) os métodos e  propriedades de outro objeto. O modelo de orientação a objetos baseado em protótipos, estabelece que um objeto serve de &#8220;molde&#8221; ou &#8220;base&#8221;  (protótipo) para outro e a herança em javascript adiciona a propriedade global  &#8220;instanceof&#8221; para definir se um objeto &#8220;é&#8221; do mesmo tipo do objeto base  (protótipo). Para implementar a herança, voce define um  objeto base (protótipo) que fornecerá as características aos outros  objetos.</p>
<p>Todos os objetos definidos pelo desenvolvedor são candidatos a  objeto base. Como medida de segurança as classes Native e Host não  estão eleitos a servirem como objetos base.</p>
<p>Selecionado o objeto base, agora voce pode criar os objetos que herdarão e modificarão o objeto base conforme os requisitos. Os  objetos filhos criados pelo desenvolvedor herdam todas as propriedades  e métodos do objeto base, incluindo o construtor e as implementações de  métodos. Lembrando que todas as propriedades e métodos são públicos,  então os objetos podem acessá-los diretamente. Esses objetos podem  adicionar novas propriedades e métodos não presentes no objeto base ou  reescrever com novas implementações.</p>
<h3>Keyword <em>This</em></h3>
<p>A palavra chave <em>This</em> faz referência ao escopo do objeto onde ela está sendo chamada.</p>
<p>Como o uso  do <em>This</em> no ECMAScript existe a possibilidade de emular os  escopos privados usando a palavra chave <em>var</em>, já que por default a linguagem só conhece o escopo  público.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> objetoY<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> variavel_privada <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Essa variável é privada&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">variavel_publica</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Essa variável é pública&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Nesse código a variável denominada &#8220;variavel_privada&#8221; não é propriedade  do objeto &#8220;objetoY&#8221; e sim uma propriedade local ao contexto desse  objeto, simulando assim uma variável privada já que outros contextos  não terão acesso a ela, apenas métodos e propriedades internas ao  objeto, enquanto a propriedade  &#8220;variavel_publica&#8221; faz parte do objeto e é de escopo público.</p>
<h3><strong>Herança via Object masquerading</strong></h3>
<p>É uma estratégia que  emula a herança, um construtor associa todas as propriedades e métodos  (com o paradigma de declaração de Construtor) usando a keyword &#8220;<em>this</em>&#8221;  para o contexto interno do qual foi referenciado. Porque o construtor é  como uma função, voce pode montar o construtor de um objeto &#8220;A&#8221; dentro  de um método de um objeto &#8220;B&#8221; e chamá-lo. O objeto &#8220;B&#8221; então recebe as  propriedades e métodos definidos no construtor de &#8220;A&#8221; porque o <em>this</em> agora aponta para o contexto do novo objeto.</p>
<p>Cria o objeto que servirá de base:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> A<span style="color: #009900;">&#40;</span>sColor<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;">color</span> <span style="color: #339933;">=</span> sColor<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sayColor</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: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">color</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: #009900;">&#125;</span></pre></div></div>

<p>Agora  eu crio o objeto chamado de &#8220;B&#8221; que herdará de &#8220;A&#8221;, quando eu chamo o  objeto &#8220;A&#8221;, ele é referenciado ao contexto interno e o &#8220;<em>this</em>&#8221; passa a pertencer a &#8220;B&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> B<span style="color: #009900;">&#40;</span>sColor<span style="color: #339933;">,</span> sName<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;">newMethod</span> <span style="color: #339933;">=</span> A<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">newMethod</span><span style="color: #009900;">&#40;</span>sColor<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;">newMethod</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">=</span> sName<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sayName</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: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">name</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: #009900;">&#125;</span></pre></div></div>

<p>Ao executar essas sentenças:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> objA <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ClassA<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'red'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> objB <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ClassB<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'blue'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Nicholas'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
objA.<span style="color: #660066;">sayColor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//outputs 'red'</span>
objB.<span style="color: #660066;">sayColor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//outputs 'blue'</span>
objB.<span style="color: #660066;">sayName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//outputs 'Nicholas'</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>objB <span style="color: #000066; font-weight: bold;">instanceof</span> A <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//false</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>objB <span style="color: #000066; font-weight: bold;">instanceof</span> B <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span></pre></div></div>

<p>Temos as mesmas chamadas de A em B com emulação completa da herança.</p>
<p>Como  perceberam, Object Masquerading suporta a implementação de múltipla  herança, mas como se trata de uma estratégia de emulação, essa abordagem não define  o tipo do objeto que herda semelhante aos tipos herdados e portanto  falha ao tentar comparar pelo &#8220;<em>instanceof</em>&#8220;.</p>
<h3><strong>Herança via métodos call() e apply()</strong></h3>
<p>Os métodos globais <em>call</em> e <em>apply</em> (que todo objeto herda do objeto Global) são estratégias semelhantes ao  &#8220;Object Masquerading&#8221; e importam o contexto de um objeto ao outro.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">call<span style="color: #009900;">&#40;</span>Objeto<span style="color: #339933;">,</span> argumento1<span style="color: #339933;">,</span> argumento2<span style="color: #339933;">,</span> ...<span style="color: #009900;">&#41;</span>
apply<span style="color: #009900;">&#40;</span>Objeto<span style="color: #339933;">,</span> array<span style="color: #339933;">-</span>de<span style="color: #339933;">-</span>argumentos<span style="color: #009900;">&#41;</span></pre></div></div>

<p>Se diferenciam somente no quesito que se refere aos parâmetros  passados, onde o método call recebe uma sequencia de parâmetros, enquanto o método apply recebe um array de parâmetros.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> nome<span style="color: #009900;">&#40;</span>sPrefixo<span style="color: #339933;">,</span> sSufixo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>sPrefixo <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">parametro_interno</span> <span style="color: #339933;">+</span> sSufixo<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> obj <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
obj.<span style="color: #660066;">parametro_interno</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Milfont'</span><span style="color: #339933;">;</span>
nome.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> <span style="color: #3366CC;">'O '</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">' é o mais elegante. '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Observe  que nesse exemplo a função &#8220;nome&#8221; está definida fora do objeto &#8220;obj&#8221; e  associa a propriedade parametro_interno a seu próprio contexto, utilizamos o método  call para passar  o objeto &#8220;obj&#8221; ao contexto da função &#8220;nome&#8221; e a  sequência de parâmetros esperados pelo seu construtor.</p>
<p>A função apply se comporta da mesma maneira e difere apenas na execução:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">nome.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'O '</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">' é o mais elegante. '</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ao invés de passar os parâmetros em sequência, passamos um array com a sequência desses parâmetros.</p>
<p>A vantagem do método apply é que toda função tem uma propriedade chamada <em>arguments</em> que herda do objeto Global e facilita a implementação:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> A<span style="color: #009900;">&#40;</span>sNome<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;">nome</span> <span style="color: #339933;">=</span> sNome<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">digaNome</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: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">nome</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: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> B<span style="color: #009900;">&#40;</span>sNome<span style="color: #339933;">,</span> sName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    A.<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: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sobrenome</span> <span style="color: #339933;">=</span> sName<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">digaSobrenome</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: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sobrenome</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: #009900;">&#125;</span></pre></div></div>

<p>Aqui  temos dentro da função &#8220;B&#8221; a chamada de &#8220;A&#8221; passando pelo método apply  o contexto de &#8220;B&#8221; para o interior da função &#8220;A&#8221;, observe que repassa a  propriedade <em>arguments </em>que é um array de argumentos recebidos.</p>
<p>Executando, teríamos:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> objA <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> A<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'martins'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> objB <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> B<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Christiano'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'milfont'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
objA.<span style="color: #660066;">digaNome</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// 'martins'</span>
objB.<span style="color: #660066;">digaNome</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// 'Christiano'</span>
objB.<span style="color: #660066;">digaSobrenome</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 'milfont'</span></pre></div></div>

<h3><strong>Herança via <em>Prototype</em></strong></h3>
<p>A  forma de herança atualmente reconhecida pela especificação é a <em>cadeia  de protótipos</em> ou <em>Prototype chaining</em>. Utilizando a propriedade <em>prototype</em> que todos os objetos herdam de Global, voce associa o contexto (métodos  e propriedades) a outro objeto e o qualifica a ser do mesmo tipo do  objeto que ele está recebendo.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> A<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
A.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">nome</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'red'</span><span style="color: #339933;">;</span>
A.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">digaNome</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: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">nome</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;">function</span> B<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
B.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> A<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Aqui a função B recebe todos os métodos e propriedades de A e passa a ser do tipo dela, executando teríamos:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> objA <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> A<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> objB <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> B<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
objA.<span style="color: #660066;">nome</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'martins'</span><span style="color: #339933;">;</span>
objB.<span style="color: #660066;">nome</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Christiano'</span><span style="color: #339933;">;</span>
objA.<span style="color: #660066;">digaNome</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// martins</span>
objB.<span style="color: #660066;">digaNome</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Christiano</span>
&nbsp;
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>objB <span style="color: #000066; font-weight: bold;">instanceof</span> A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>objB <span style="color: #000066; font-weight: bold;">instanceof</span> B<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span></pre></div></div>

<p>Formas híbridas podem ser usadas, mesclando esses métodos na construção dos objetos.</p>
<h3><strong>Multipla herança</strong></h3>
<p>Algumas linguagens orientadas a  objetos habilitam o suporte à múltipla herança. Que é a capacidade de  um objeto herdar as propriedades (métodos e atributos) de mais de um  objeto. Além que esse objeto passa a ser da espécie dos objetos que ele  herda, como por exemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> Passaro<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;">nome</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'papagaio'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> Produto<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;">valor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'R$10,00'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
Passaro.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Produto<span style="color: #339933;">;</span>
Passaro.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">imprimir</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; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">valor</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' - '</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">nome</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Uma classe PetStore poderia realizar um teste se o periquito é dos  tipos Produto e Passaro para aplicar medicamento adequado à espécie por  exemplo, esse tipo de construção é comum em linguagens como C, é simulado em Java por meio de interfaces.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> passaro <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Passaro<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>passaro <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #009900;">&#40;</span>Produto<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// saida: true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>passaro <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #009900;">&#40;</span>Passaro<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// saida: true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>passaro.<span style="color: #660066;">imprimir</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: #006600; font-style: italic;">// saida: &quot;R$10,00 - papagaio&quot;</span></pre></div></div>

<p>Javascript não suporta múltipla herança pelo método de prototype que é  o método que define o tipo do objeto, existe entretanto como contornar  isso, um exemplo é a biblioteca zInherit  (<a href="http://www.nczonline.net/downloads/">http://www.nczonline.net/downloads/</a>) de Nicholas C. Zakas  (<a href="http://www.nczonline.net/writing/">http://www.nczonline.net/writing/</a>), autor dos excelentes livros  &#8220;Professional Ajax&#8221; e &#8220;Professional JavaScript for Web  Developers&#8221;.</p>
<p>Esse script acrescenta os métodos inheritFrom e instanceOf ao objeto nativo Object.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> Biologia<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;">reino</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'animal'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> Produto<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;">valor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'R$10,00'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> Passaro<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    Produto.<span style="color: #660066;">apply</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>
    Biologia.<span style="color: #660066;">apply</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;">nome</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'periquito'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
Passaro.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">inheritFrom</span><span style="color: #009900;">&#40;</span>Produto<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Passaro.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">inheritFrom</span><span style="color: #009900;">&#40;</span>Biologia<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Passaro.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">imprimir</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; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">reino</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' - '</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">valor</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' - '</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">nome</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> passaro <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Passaro<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>passaro.<span style="color: #000066; font-weight: bold;">instanceOf</span><span style="color: #009900;">&#40;</span>Produto<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//saida : true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>passaro.<span style="color: #000066; font-weight: bold;">instanceOf</span><span style="color: #009900;">&#40;</span>Biologia<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//saida : true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>passaro <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #009900;">&#40;</span>Passaro<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//saida : true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>passaro.<span style="color: #660066;">imprimir</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: #006600; font-style: italic;">// saida: &quot;animal - R$10,00 - papagaio&quot;</span></pre></div></div>

<p>O metodo apply() habilita a aplicar um método de outro objeto no contexto de um objeto diferente.</p>
<p>Os frameworks modernos como ExtJS e YUI tem suas formas de implementarem a múltipla herança. Uma das formas mais utilizadas pelos <a href="http://www.milfont.org/tech/2007/10/11/frameworks-ajax/">Frameworks Ajax</a> é copiarem os métodos e variáveis de um protótipo ao objeto que herdará.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.milfont.org/tech/2008/01/05/heranca-no-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>O que é JSON</title>
		<link>http://www.milfont.org/tech/2007/11/04/o-que-e-json/</link>
		<comments>http://www.milfont.org/tech/2007/11/04/o-que-e-json/#comments</comments>
		<pubDate>Sun, 04 Nov 2007 09:21:35 +0000</pubDate>
		<dc:creator>cmilfont</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Crockford]]></category>
		<category><![CDATA[ECMAScript]]></category>

		<guid isPermaLink="false">http://www.milfont.org/tech/2007/11/04/o-que-e-json/</guid>
		<description><![CDATA[A especificação do &#8220;ECMA Script&#8221; (ECMA262, 3rd Edition, December 1999), que formaliza o Javascript, define na página 2 (4.2) a sentença: &#8220;An ECMAScript object is an unordered collection of properties each with zero or more attributes&#8230;&#8221; Essa definição é o que chamamos de objeto literal, uma coleção não ordenada de propriedades com um ou mais [...]]]></description>
			<content:encoded><![CDATA[<p>A especificação do &#8220;ECMA  Script&#8221; (<a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf">ECMA262</a>, 3rd Edition, December 1999), que formaliza o Javascript, define na página 2 (4.2) a sentença:</p>
<p><cite>&#8220;An ECMAScript object is an unordered collection of properties each with zero or more attributes&#8230;&#8221; </cite></p>
<p>Essa definição é o que chamamos de objeto literal, uma coleção não ordenada de propriedades com um ou mais elementos, onde esses elementos podem ser valores primitivos comuns a todas as linguagens como: inteiro, string ou char; ou outros objetos.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Produto <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	nome<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Microprocessador AMD Turion 64&quot;</span><span style="color: #339933;">,</span>
	value<span style="color: #339933;">:</span><span style="color: #CC0000;">150</span><span style="color: #339933;">,</span>
	custo<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span>
	getValue<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;">&#40;</span>value <span style="color: #339933;">+</span> custo<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Douglas <a href="http://www.crockford.com/">Crockford</a>, propôs um  formato de troca de dados simples com base no objeto literal do JavaScript, que denominou de <a href="http://www.json.org/">JSON</a> (JavaScript Object Notation). Esse mecanismo simples é um subconjunto do objeto literal e é facil de qualquer linguagem processar e gerar por ser baseado no formato texto, como linguagem completamente independente que usa conceitos similares às linguagens C-like. Esses motivos tornam o JSON o formato ideal de troca de dados.</p>
<p>JSON é construído com base em uma coleção de pares chave/valor (que definem as propriedades e seus valores), iniciado com &#8220;{&#8221; (chave aberta) e finalizado com &#8220;}&#8221; (chave fechada) . Cada chave é seguida de &#8220;:&#8221; (dois pontos) e os pares são separados por &#8220;,&#8221; (vírgula).</p>
<p><img src="http://json.org/object.gif" alt="objeto json" /></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Contato <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;nome&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Christiano Milfont&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;email&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;cmilfont@gmail.com&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;aniversário&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;28/12/1977&quot;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Um array pode ser usado como valor para uma chave, iniciado por &#8220;[" (colchete aberto) e finalizado por "]&#8221; (colchete fechado). Cada valor do array é separado por &#8220;,&#8221; (vírgula).</p>
<p><img src="http://json.org/array.gif" alt="array json" /></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Contato <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;nome&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Christiano Milfont&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;telefones&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>
		<span style="color: #3366CC;">'91942365'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'88293759'</span>
	<span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Um valor pode ser uma String em aspas duplas (em javascript o valor pode ser aspa simples, é preferível que o parser resolva as duas formas, apesar de que em linguagens como java as aspas simples representam um char), ou um número, ou um booleano, ou um null, ou um outro objeto ou um array.</p>
<p><img src="http://json.org/value.gif" alt="valores json" /></p>
<p>No caso do objeto e do array, essas estrutura podem ser aninhadas.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Contato <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;nome&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Christiano Milfont&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;endereco&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">&quot;rua&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Eurico Medina&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;numero&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">185</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">&quot;mapa&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">&quot;latitude&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">&quot;longitude&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;&quot;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;telefones&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>
		<span style="color: #3366CC;">'91942365'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'88293759'</span>
	<span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>String é uma coleção de zero ou mais caracteres <a href="http://pt.wikipedia.org/wiki/Unicode">Unicode</a>, onde a barra invertida pode ser usada para passar caracteres especais como quebra de linha, tab, entre outros. Números podem ser inteiros ou reais, menos hexadecimal ou octal.</p>
<p>Existem códigos de processamento JSON prontos em dezenas de linguagens, praticamente em todas as linguagens modernas voce encontra no <a href="http://www.json.org/">site do projeto</a>.</p>
<p>A vantagem do JSON sobre o XML como formato de troca de dados é a diminuição do tamanho da resposta, facilidade de entendimento para o programador (já que o código é similiar a linguagem que você usa), e principalmente, no caso de javascript, o parser facilitado porque é baseado em sua especificação de objeto.</p>
<p>Código de retorno do Flickr em <a href="http://www.flickr.com/services/rest/?method=flickr.test.echo&amp;format=soap2&amp;foo=bar&amp;api_key=08d9221b2468be6ccfe5bc229db50181">XML</a> e <a href="http://www.flickr.com/services/rest/?method=flickr.test.echo&amp;format=json&amp;api_key=08d9221b2468be6ccfe5bc229db50181">JSON</a> respectivamente:</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243; ?&gt;<br />
&lt;s:Envelope xmlns:s=&#8221;http://www.w3.org/2003/05/soap-envelope&#8221;&gt;<br />
&lt;s:Body&gt;<br />
&lt;FlickrResponse xmlns=&#8221;http://flickr.com/ns/api#&#8221;&gt;<br />
&lt;method&gt;flickr.test.echo&lt;/method&gt;<br />
&lt;format&gt;soap2&lt;/format&gt;<br />
&lt;foo&gt;bar&lt;/foo&gt;<br />
&lt;api_key&gt;08d9221b2468be6ccfe5bc229db50181&lt;/api_key&gt;<br />
&lt;/FlickrResponse&gt;<br />
&lt;/s:Body&gt;<br />
&lt;/s:Envelope&gt;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
jsonFlickrApi<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">&quot;_content&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;flickr.test.echo&quot;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;format&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">&quot;_content&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;json&quot;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;api_key&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">&quot;_content&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;08d9221b2468be6ccfe5bc229db50181&quot;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;stat&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;ok&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Dessa forma você pode usar as estratégias de &#8220;<a href="http://www.milfont.org/tech/2007/10/02/eval-is-evil/">Eval</a>&#8221;  ou &#8220;<a href="http://www.milfont.org/tech/2007/10/08/script-tag/">Scripttag</a>&#8221; para processar o JSON de forma transparente em sua aplicação AJAX. Usado como configuração em aplicações no lado servidor, você pode construir uma arquitetura com base em interfaces para validar os dados, assim como validaria usando schemas no XML.</p>
<p>A maioria das APIs  de web services dos principais Players no mercado WEB, passaram a oferecer o JSON como alternativa ao XML pela facilidade de interpretação para a arquitetura REST. <a href="http://developer.yahoo.com/common/json.html">Yahoo</a> e <a href="http://code.google.com/apis/gdata/json.html">Google</a> são os principais expoentes desse mecanismo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.milfont.org/tech/2007/11/04/o-que-e-json/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

