<?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>Web 3.0, 6 Bladed Razors, 7 Minute Abs &#187; Dojo</title>
	<atom:link href="http://www.zachleat.com/web/tag/dojo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web</link>
	<description></description>
	<lastBuildDate>Fri, 09 Dec 2011 21:53:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Rethinking JavaScript Grids and DataTables</title>
		<link>http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/</link>
		<comments>http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 20:29:26 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Conservative Design]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=122</guid>
		<description><![CDATA[In the world of front end engineering, one must consider the end-user of the interface first, and above all other things. The priorities should not start with development ease, nor external library preference. The priorities should start with the needs of the consumer of your end product. Evolution of your engineering skill is also a [...]]]></description>
			<content:encoded><![CDATA[<p>In the world of front end engineering, one must consider the end-user of the interface first, and above all other things.  The priorities should not start with development ease, nor external library preference.  The priorities should start with the needs of the consumer of your end product.</p>
<p>Evolution of your engineering skill is also a vital trait in this world, which means that as a developer increases his knowledge of good practices and proper methods, sometimes he must shirk his previous assertions about the world as he previously knew it.  And today I&#8217;m shirking a staple of the front end as all web users know it: The Grid (DataTable) Component.</p>
<p>Of course, I&#8217;ve written a few articles in the past about the <a href="http://developer.yahoo.com/yui/datatable/">YUI DataTable</a>, during my long love affair with Yahoo&#8217;s User Interface library.  Another popular one is jQuery&#8217;s <a href="http://tablesorter.com/docs/">TableSorter</a>.  Then there&#8217;s the <a href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid">Dojo Grid</a>, a component <a href="http://www.sitepen.com/blog/2007/09/16/the-dojo-grid/">inherited from TurboAjax</a>.  ExtJS has a variety of nice examples as well for their <a href="http://extjs.com/deploy/dev/examples/#sample-1">Ext 2.0 Grid</a>.</p>
<p>And after using these Grids and DataTables, I certainly respect the programming that went into developing these components.  But let&#8217;s take a step back for a second.  Why do the users need the bells and whistles in these components?  Are they worth the extra load time and complexity they add to the interface?</p>
<p>All we&#8217;re doing here is putting a nice coat of paint on a &lt;table&gt; tag.  Sure, it might have some nice ancillary features like Ajax Data Loading, but those don&#8217;t really matter &#8211; they are things that can be easily performed with some good Ajax and DOM insert utility functions.  In fact, most of the core features included in these components could be described as feature creep, and not beneficial to the end user at all.  Feature creep contributes to code bloat, which means the user is downloading bytes to their web browser that they don&#8217;t need, which can hamper performance.  Libraries usually have online examples of their components, and the include sizes are seen below.  (Gzip compression not considered)</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>JavaScript Size</th>
<th>Minimized</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<tr>
<td>YUI DataTable</td>
<td>216.6 KB</td>
<td>Minimized</td>
<td><a href="http://developer.yahoo.com/yui/examples/datatable/dt_basic_clean.html">Example</a></td>
</tr>
<tr>
<td>Dojo Grid</td>
<td>338.4 KB</td>
<td>Unminimized</td>
<td><a href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid/simple-grid">Example</a></td>
</tr>
<tr>
<td>Ext Grid</td>
<td>545.5 KB</td>
<td>Minimized</td>
<td><a href="http://extjs.com/deploy/dev/examples/grid/array-grid.html">Example</a></td>
</tr>
<tr>
<td>jQuery TableSorter</td>
<td>66 KB</td>
<td>Minimized</td>
<td><a href="http://www.tablesorter.com/">Example</a></td>
</tr>
</tbody>
</table>
<p>The JavaScript include sizes listed above are directly proportional to the feature set that the components provide, and should give you an idea of the overhead involved with using them.  Do we need 545.5 KB of features coming down the pipe to give our users an extra bell, or an extra whistle?  Let&#8217;s analyze the features to rationalize their usage, and remove items from the feature set.</p>
<ul>
<li>Sorting</li>
<li>Modifying column order and display</li>
<li>Resizing columns</li>
<li>Editing of row data directly on the grid itself</li>
<li>Scrolling</li>
<li>Pagination</li>
</ul>
<p><strong>Sorting</strong></p>
<p>Data should be used in the context of its usefulness.  You have a list of messages in your e-mail inbox.  What&#8217;s the most useful context for this list?  In order of date received.  The default sort order provided by the application, to facilitate proper use of the application.  Is comparing the rows in the grid by any other method as useful?  Does the user need to see the list of messages ordered alphabetically by subject?  In these cases where the user is in need of a specific message, <em>searching and filtering</em> is more useful than sorting.  The default sort is useful, but allowing the user to resort on the client, in most cases, is not as useful as other methods of finding a row.</p>
<p><strong>Modifying column order and display</strong></p>
<p>The same argument can be made for any of the other methods of customization provided to the end user.  Does the user need to reorder or hide columns?  The context provided by the application should be sufficient to use the applications data in the way it was intended.  Don&#8217;t overcomplicate your user interface with needless features or a deluge of useless data.  Provide succinct, appropriate data, and the user needn&#8217;t reorder or change the interface.</p>
<p><strong>Resizing columns</strong></p>
<p>The default HTML &lt;table&gt; tag expands to fit the data inside of its cells.  Even when you set the width of the table explicitly, the cells adjust themselves accordingly to fit the data.  This should be the behavior of your table.  You needn&#8217;t monkey around with widths, the browser is smart enough to do it for you.  You can even customize a cell to wrap its text to multiple lines with CSS, if need be.</p>
<p><strong>Editing of row data directly on the grid itself</strong></p>
<p>If you&#8217;re providing an Excel spreadsheet interface for the end user to customize your data, you haven&#8217;t designed your interface correctly.  Rethink how the user needs to interact with the data you&#8217;ve provided, and give them a better, simpler way to edit the data.</p>
<p><strong>Scrolling</strong></p>
<p>Everyone knows that internal scrollbars on a page are evil.  I don&#8217;t even like scrollbars on textareas, to be honest.  Previously, I had worked and reworked the YUI DataTable to handle horizontal scrolling.  Looking back on this, it was a mistake.  There are better ways to handle lots of data in a table, without the heavy mouse interaction and scanning that scrolling require.  Which brings me to my next point.</p>
<p><strong>Pagination</strong></p>
<p>This is the one exception to the feature set cutting board.  This is the one feature that&#8217;s is a requirement, when the data set has too many records to fit on a single page.</p>
<p>Keep these in mind, and look at the feature set provided by a few sites using tabular data centric interfaces that know a thing or two about interface design:</p>

<a href='http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/gmail/' title='Google Mail'><img width="150" height="150" src="http://www.zachleat.com/web/wp-content/uploads/2008/04/gmail-150x150.png" class="attachment-thumbnail" alt="Google Mail" title="Google Mail" /></a>
<a href='http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/wordpress-admin/' title='Wordpress 2.5 Admin Interface'><img width="150" height="150" src="http://www.zachleat.com/web/wp-content/uploads/2008/04/wordpress-admin-150x150.png" class="attachment-thumbnail" alt="Wordpress 2.5 Admin Interface" title="Wordpress 2.5 Admin Interface" /></a>
<a href='http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/google-reader/' title='Google Reader List View'><img width="150" height="150" src="http://www.zachleat.com/web/wp-content/uploads/2008/04/google-reader-150x150.png" class="attachment-thumbnail" alt="Google Reader List View" title="Google Reader List View" /></a>

<p><strong>So, what should we include?</strong></p>
<p>A simple CSS class to style your table is sufficient, with links to paginate the table (properly) and/or a hover for row selection if needed.  You&#8217;re looking at 10-20 lines of jQuery code, maximum, and a few CSS declarations.  In lieu of sorting, of course, you&#8217;ll need to program in a mechanism for searching and filtering as well.  But really, the difficulty with programming this component is knowing what to leave out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>JavaScript Frameworks and JSF</title>
		<link>http://www.zachleat.com/web/javascript-frameworks-and-jsf/</link>
		<comments>http://www.zachleat.com/web/javascript-frameworks-and-jsf/#comments</comments>
		<pubDate>Wed, 11 Jul 2007 02:24:05 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Facelets]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/07/10/javascript-frameworks-and-jsf/</guid>
		<description><![CDATA[You&#8217;re programming a new web application using JSF, maybe with Facelets, maybe without. Which client-side JavaScript framework is going to work with it&#8217;s unstandardized method of assigning ID attributes to it&#8217;s elements? Here is an example of a JSF file: &#60;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %&#62; &#60;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %&#62; &#60;html&#62; &#60;body&#62; &#60;f:view&#62; &#60;h:form id="myForm"&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re programming a new web application using JSF, maybe with Facelets, maybe without.  Which client-side JavaScript framework is going to work with it&#8217;s unstandardized method of assigning ID attributes to it&#8217;s elements?  Here is an example of a JSF file:<br />
<code><br />
&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %&gt;<br />
&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %&gt;<br />
&lt;html&gt;<br />
 &lt;body&gt;<br />
   &lt;f:view&gt;<br />
     &lt;h:form id="myForm"&gt;<br />
      &lt;h:inputText id="myText"/&gt;<br />
     &lt;/h:form&gt;<br />
   &lt;/f:view&gt;<br />
 &lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>or maybe the same thing using Facelets:<br />
<code><br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"<br />
      xmlns:h="http://java.sun.com/jsf/html"<br />
      xmlns:f="http://java.sun.com/jsf/core"&gt;<br />
 &lt;body&gt;<br />
   &lt;f:view&gt;<br />
     &lt;form jsfc="h:form" id="myForm"&gt;<br />
      &lt;input type="text" jsfc="h:inputText" id="myText"/&gt;<br />
     &lt;/form&gt;<br />
   &lt;/f:view&gt;<br />
 &lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>These will both output the following result:<br />
<code><br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"<br />
      xmlns:ui="http://java.sun.com/jsf/facelets"&gt;<br />
 &lt;body&gt;<br />
     &lt;form id="myForm"&gt;<br />
      &lt;input type="text" id="myForm:myText"/&gt;<br />
     &lt;/form&gt;<br />
 &lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>Notice how the resulting text field has an ID attribute with the parent id prepended on.  Now the real question is, how do we select this result node using the various JavaScript frameworks that are available to us?</p>
<h1>Works, but we don&#8217;t care: Raw JavaScript or any GetById Function</h1>
<p>Obviously using <code>document.getElementById( 'myForm:myText' );</code> will function correctly.  As will any framework that has a similar &#8220;GetById&#8221; function (YAHOO.util.Dom.get, or $ in Prototype, etc)  What is more interesting to us is the behavior using the various CSS selector packages included with each JavaScript library.</p>
<h1>Does not work: <a href="http://extjs.com/deploy/ext/docs/output/Ext.DomQuery.html">DomQuery</a> in Ext 1.1 Beta 2</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>These two tests will throw the error <code>Ext.DomQuery.pseudos[name] is not a function</code>, which obviously means that myText is not a pseudo class like :first or :last.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Throws the error: <code>Error parsing selector, parsing failed at "\:myText"</code></p>
<h1>Works: <a href="http://docs.jquery.com/DOM/Traversing/Selectors">jQuery</a> 1.1.3</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As of version 1.1.3 (the latest of this writing), they have added support for the colon in ID selection when escaped with a double backslash.  Versions older than 1.1.3 will not function properly.  This is not yet in the documentation but can be viewed in the <a href="http://jquery.com/blog/2007/07/01/jquery-113-800-faster-still-20kb/">Escape selectors section of a blog post</a>.</p>
<h1>Does not Work: <a href="http://www.prototypejs.org/api/utility/dollar-dollar">Prototype</a> 1.5.1.1</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Returns the form instead of the input element and treats myText as a pseudo class.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Interprets as XPATH selectors (\\ means anywhere in the document), using myText as a pseudo selector now, so it returns ALL nodes in the document.</p>
<h1>Does not Work: <a href="http://dojotoolkit.org/node/336">Dojo query</a> 0.9.0 Beta</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dojo.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dojo.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It&#8217;s becoming mind numbingly obvious that if the framework doesn&#8217;t specifically say that you can escape selectors, it&#8217;s not going to let you do so.  In the first two tests, Dojo performs the same as Prototype.  In the double backslash test however, Dojo returns no result nodes.</p>
<h1>Does not Work: <a href="http://docs.mootools.net/Element/Element-Selectors.js">Mootools</a> 1.11</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>All throw the error <code>The expression is not a legal expression." code: "51</code>.</p>
<p>There you have it folks.  jQuery is the JavaScript library of choice for the discerning JSF applications developer.  Kudos to you if you&#8217;re already using it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/javascript-frameworks-and-jsf/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

