<?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"
	>

<channel>
	<title>Web 3.0, 6 Bladed Razors, 7 Minute Abs &#187; Java</title>
	<atom:link href="http://www.zachleat.com/web/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web</link>
	<description></description>
	<pubDate>Thu, 21 Aug 2008 06:02:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Surnamespacing</title>
		<link>http://www.zachleat.com/web/2008/05/07/surnamespacing/</link>
		<comments>http://www.zachleat.com/web/2008/05/07/surnamespacing/#comments</comments>
		<pubDate>Thu, 08 May 2008 01:30:31 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
		
		<category><![CDATA[Humor]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=133</guid>
		<description><![CDATA[Everyone has a library.  Everyone has their own utility classes and functions they're using in their own personal and contracted projects.  And now that everyone has a blog too, they're all releasing their libraries as open source, using the commando underoo philosophy of wild, free, and unrestricted naming schemes for their code.  Not anymore.  Let's surnamespace.]]></description>
			<content:encoded><![CDATA[<p>Everyone has a library.  Everyone has their own utility classes and functions they're using in their own personal and contracted projects.  And now that everyone has a blog too, they're all releasing their libraries as open source, using the commando underoo philosophy of wild, free, and unrestricted naming schemes for their code.  Not anymore.  Let's surnamespace.</p>
<p>What does surnamespacing give me?</p>
<ul>
<li><strong>Accountability</strong>: Your code is directly linked to your family honor.  You'd be surprised how hard people work at test cases and increased code coverage when the respect of their lineage is at stake.</li>
<li><strong>Connect</strong> with your Extended Family: Connect with programmers sharing your namespace, your family is now your development team.</li>
<li><strong>Minimize Collisons</strong>: The ball and chain associated with an imposed naming scheme means that we won't have everyone using foo and bar to hold their code, unless you're the lucky son of a bitch that has inherited that top notch surnamespace real estate.</li>
<li><strong>Faster</strong> Initial Development Cycle: Sometimes naming your library is the hardest part.  Skip this step and just surnamespace it.</li>
<p>Jesus Christ, please show me some examples:</p>
<p><strong>JavaScript Surnamespacing</strong></p>
<div class="syntax_hilite">
<div id="javascript-1">
<div class="javascript"><span style="color: #003366; font-weight: bold;">var</span> Christ = <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; Jesus: <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; walkOn: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; turn: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>from, to<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; respawn: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span>;<br />
<span style="color: #009900; font-style: italic;">// Sample Usage</span><br />
Christ.<span style="color: #006600;">Jesus</span>.<span style="color: #006600;">walkOn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'water'</span><span style="color: #66cc66;">&#41;</span>;<br />
Christ.<span style="color: #006600;">Jesus</span>.<span style="color: #006600;">turn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'water'</span>, <span style="color: #3366CC;">'wine'</span><span style="color: #66cc66;">&#41;</span>;<br />
Christ.<span style="color: #006600;">Jesus</span>.<span style="color: #006600;">respawn</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p><strong>Java Surnamespacing</strong></p>
<div class="syntax_hilite">
<div id="java-2">
<div class="java">package Christ;<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Jesus <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> walkOn<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> s<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> turn<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> from, <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> to<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> respawn<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></p>
<p><strong>PHP 6 Surnamespacing (<a href="http://php.net/~derick/meeting-notes.html">projected usage</a>)</strong></p>
<div class="syntax_hilite">
<div id="php-3">
<div class="php">namespace Christ <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">class</span> Jesus <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> walkOn<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$obj</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> turn<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$from</span>, <span style="color:#0000FF;">$to</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> respawn<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<p><strong>Update</strong>: Apparently I can't write Java code.  Don't tell work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2008/05/07/surnamespacing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScript Frameworks and JSF</title>
		<link>http://www.zachleat.com/web/2007/07/10/javascript-frameworks-and-jsf/</link>
		<comments>http://www.zachleat.com/web/2007/07/10/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're programming a new web application using JSF, maybe with Facelets, maybe without.  Which client-side JavaScript framework is going to work with it's unstandardized method of assigning ID attributes to it'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;
  [...]]]></description>
			<content:encoded><![CDATA[<p>You're programming a new web application using JSF, maybe with Facelets, maybe without.  Which client-side JavaScript framework is going to work with it's unstandardized method of assigning ID attributes to it'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'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 "GetById" 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="syntax_hilite">
<div id="javascript-17">
<div class="javascript">Ext.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="javascript-18">
<div class="javascript">Ext.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<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="syntax_hilite">
<div id="javascript-19">
<div class="javascript">Ext.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<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="syntax_hilite">
<div id="javascript-20">
<div class="javascript">jQuery<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<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="syntax_hilite">
<div id="javascript-21">
<div class="javascript">$$<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="javascript-22">
<div class="javascript">$$<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>Returns the form instead of the input element and treats myText as a pseudo class.</p>
<div class="syntax_hilite">
<div id="javascript-23">
<div class="javascript">$$<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<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="syntax_hilite">
<div id="javascript-24">
<div class="javascript">dojo.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="javascript-25">
<div class="javascript">dojo.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="javascript-26">
<div class="javascript">dojo.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>It's becoming mind numbingly obvious that if the framework doesn't specifically say that you can escape selectors, it'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="syntax_hilite">
<div id="javascript-27">
<div class="javascript">$$<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="javascript-28">
<div class="javascript">$$<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="javascript-29">
<div class="javascript">$$<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<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're already using it.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/JSF" rel="tag">JSF</a>, <a href="http://technorati.com/tag/Facelets" rel="tag"> Facelets</a>, <a href="http://technorati.com/tag/JavaScript" rel="tag"> JavaScript</a>, <a href="http://technorati.com/tag/Ext" rel="tag"> Ext</a>, <a href="http://technorati.com/tag/mootools" rel="tag"> mootools</a>, <a href="http://technorati.com/tag/Dojo" rel="tag"> Dojo</a>, <a href="http://technorati.com/tag/jQuery" rel="tag"> jQuery</a>, <a href="http://technorati.com/tag/Prototype" rel="tag"> Prototype</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/07/10/javascript-frameworks-and-jsf/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
