<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Stupid Problems that Frustrate me</title><link>http://blogs.acceleration.net/russ/category/44.aspx</link><description>This is the solution to stupid problems that I have found</description><managingEditor>Russ</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Russ</dc:creator><title>I suppose I should have mentioned it ...</title><link>http://blogs.acceleration.net/russ/archive/2006/08/15/3005.aspx</link><pubDate>Tue, 15 Aug 2006 09:57:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2006/08/15/3005.aspx</guid><description>I have a new blog intended to replace this one.  For whatever reason, I cannot get dotText to export my posts correctly.  I plan on keeping this site up for a while, but all new content is at: &lt;a href="http://russ.unwashedmeme.com/blog"&gt;http://russ.unwashedmeme.com/blog&lt;/a&gt;.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/3005.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">I have a new blog intended to replace this one.  For whatever reason, I cannot get dotText to export my posts correctly.  I plan on keeping this site up for a while, but all new content is at: <a href="http://russ.unwashedmeme.com/blog">http://russ.unwashedmeme.com/blog</a>.<img src ="http://blogs.acceleration.net/russ/aggbug/3005.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>LINQ preview and Lisp</title><link>http://blogs.acceleration.net/russ/archive/2006/03/01/2835.aspx</link><pubDate>Wed, 01 Mar 2006 11:26:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2006/03/01/2835.aspx</guid><description>I really wanted to be excited about .Net 2.0 and C#'s 3.0 LINQ preview.   However, between .Net1.1 and .Net2 coming out, I started to play with LISP.
&lt;br /&gt;&lt;br /&gt;
First, I was digging through some C# 2.0 the other day (now with Generics and "Anonymous Delegates Outer variable capture" (craptastic, hacked, statically typed closures)),  and while reading a blogpost (that I lost, sorry) the blogger maid the excellent point that in removing static typing from some things (generics) they had to add reams of code.  Something there should smell bad already.  If you find yourself adding reams of code (and more, new syntax) to get away with leaving out half of what the language originally made you specify, maybe the language just shouldn't force you to specify that info.  I dunno maybe I'm crazy and/or stupid and/or a type-ist?(someone who's against typing?).
&lt;br /&gt;&lt;br /&gt;
On to LINQ: When I saw &lt;a href="http://weblog.infoworld.com/udell/2005/09/28.html"&gt;this forthcoming tech, LINQ&lt;/a&gt;, I thought, "Hey relational algebra-ish support inside of the language, nice".  Then I looked at the demo and the only thing I can think of is all of the lisp constructs to do this sort of high end querying.  All of the LISP ways that were built into the language long before its standardization (ANSI standardization: December 8, 1994) a decade ago.  I am fairly sure that Ruby blocks can be put to use to accomplish this same sort of thing.  Also Python list comprehensions.  It really makes me question why people are willing to wait another 2-3 years for LINQ when they are a download away from better, more dynamic frameworks.  Oh... right... its next to impossible to talk to sql server outside of an MS environment (vendor lockin).   And as always learning anything new (that isnt ms )

&lt;div style="white-space:pre;"&gt;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; C# Linq Demo from &lt;a href="http://weblog.infoworld.com/udell/2005/09/28.html"&gt;this .net blog&lt;/a&gt;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
XDocument doc = XDocument.Load("blog.xml");
 
var d  = new Dictionary&lt;string,string&gt;();
d.Add("2005/09","September 2005");
d.Add("2005/08","August 2005");
 
var a = new string[] { "greasemonkey", "ajax" };
 
var query =
  from
    item in doc.Descendants("item"),
    key in d.Keys,
    tag in a
  where item.Element("date").Value.Contains(key) &amp;amp;&amp;amp;
        item.Element("tags").Value.Contains(tag)
  orderby
    (string) item.Element("date") descending
  select new XElement("item",
    new XElement("month",d[key]),
    item.Element("date"),
    item.Element("title"),
    item.Element("tags"));
 
foreach (var result in query)
  Console.WriteLine(result);

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lisp with Loop which as far as I can tell is about as close as I can get LINQ
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(mapc
 (lambda (elem) (print elem))
 
  (loop for item in doc.Decendants("items")
	for key in d.Keys
	for tag in a
	when (and
	      item
	      (find key (value (item.Element "date")))
	      (find tag (value (item.Element "tags"))))
	collect (make-instance 'XElement
			      :tag-name "month"
			      :children (list (make-instance 'XElement :tag-name "month")
					      (item.Element "date")
					      (item.Element "title")
					      (item.Element "tags")))
	into new-elems
	unless item do (return (sort new-rows #'xml-item-date-&amp;lt; )))  
&lt;/string,string&gt;&lt;/div&gt;&lt;br /&gt;

There might be more that I am missing (for example an XML library (use ClosureXML), and a predicate that will work for the sorting he wants).  About the nicest part of the LINQ stuff seems to be the OrderBy clause (also possibly GroupBy which isnt covered in the demo, but I could see being cool). However, sorting is more or less a done job given an appropriate predicate. Also there might be slightly more involved iterating going on in the query, but nothing that couldnt be handled with a modicum more code, wrapped in a macro to give it that linq-ish look, and packaged up to be useful in a week.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/2835.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">I really wanted to be excited about .Net 2.0 and C#'s 3.0 LINQ preview.   However, between .Net1.1 and .Net2 coming out, I started to play with LISP.
<br /><br />
First, I was digging through some C# 2.0 the other day (now with Generics and "Anonymous Delegates Outer variable capture" (craptastic, hacked, statically typed closures)),  and while reading a blogpost (that I lost, sorry) the blogger maid the excellent point that in removing static typing from some things (generics) they had to add reams of code.  Something there should smell bad already.  If you find yourself adding reams of code (and more, new syntax) to get away with leaving out half of what the language originally made you specify, maybe the language just shouldn't force you to specify that info.  I dunno maybe I'm crazy and/or stupid and/or a type-ist?(someone who's against typing?).
<br /><br />
On to LINQ: When I saw <a href="http://weblog.infoworld.com/udell/2005/09/28.html">this forthcoming tech, LINQ</a>, I thought, "Hey relational algebra-ish support inside of the language, nice".  Then I looked at the demo and the only thing I can think of is all of the lisp constructs to do this sort of high end querying.  All of the LISP ways that were built into the language long before its standardization (ANSI standardization: December 8, 1994) a decade ago.  I am fairly sure that Ruby blocks can be put to use to accomplish this same sort of thing.  Also Python list comprehensions.  It really makes me question why people are willing to wait another 2-3 years for LINQ when they are a download away from better, more dynamic frameworks.  Oh... right... its next to impossible to talk to sql server outside of an MS environment (vendor lockin).   And as always learning anything new (that isnt ms )

<div style="white-space:pre;">
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; C# Linq Demo from <a href="http://weblog.infoworld.com/udell/2005/09/28.html">this .net blog</a>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
XDocument doc = XDocument.Load("blog.xml");
 
var d  = new Dictionary<string,string>();
d.Add("2005/09","September 2005");
d.Add("2005/08","August 2005");
 
var a = new string[] { "greasemonkey", "ajax" };
 
var query =
  from
    item in doc.Descendants("item"),
    key in d.Keys,
    tag in a
  where item.Element("date").Value.Contains(key) &amp;&amp;
        item.Element("tags").Value.Contains(tag)
  orderby
    (string) item.Element("date") descending
  select new XElement("item",
    new XElement("month",d[key]),
    item.Element("date"),
    item.Element("title"),
    item.Element("tags"));
 
foreach (var result in query)
  Console.WriteLine(result);

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lisp with Loop which as far as I can tell is about as close as I can get LINQ
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(mapc
 (lambda (elem) (print elem))
 
  (loop for item in doc.Decendants("items")
	for key in d.Keys
	for tag in a
	when (and
	      item
	      (find key (value (item.Element "date")))
	      (find tag (value (item.Element "tags"))))
	collect (make-instance 'XElement
			      :tag-name "month"
			      :children (list (make-instance 'XElement :tag-name "month")
					      (item.Element "date")
					      (item.Element "title")
					      (item.Element "tags")))
	into new-elems
	unless item do (return (sort new-rows #'xml-item-date-&lt; )))  
</string,string></div><br />

There might be more that I am missing (for example an XML library (use ClosureXML), and a predicate that will work for the sorting he wants).  About the nicest part of the LINQ stuff seems to be the OrderBy clause (also possibly GroupBy which isnt covered in the demo, but I could see being cool). However, sorting is more or less a done job given an appropriate predicate. Also there might be slightly more involved iterating going on in the query, but nothing that couldnt be handled with a modicum more code, wrapped in a macro to give it that linq-ish look, and packaged up to be useful in a week.<img src ="http://blogs.acceleration.net/russ/aggbug/2835.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Could not find installable ISAM</title><link>http://blogs.acceleration.net/russ/archive/2006/02/22/2831.aspx</link><pubDate>Wed, 22 Feb 2006 13:02:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2006/02/22/2831.aspx</guid><description>So when trying to read from excel files we got this message repeatedly, and could not figure out what the hell it meant.  We tried reinstalling some dlls that were suggested by other blog posts, but nothing would make the excel file open.  Turns out, our connection string was wrong.  &lt;br /&gt;&lt;br /&gt;

This is a basic correct connection string.
"Provider=Microsoft.Jet.OleDb.4.0;data source=[FILE_PATH];Extended Properties=Excel 8.0;"
&lt;br /&gt;&lt;br /&gt;
UPDATE: &lt;a href="http://blogs.wdevs.com/Gaurang/archive/2005/06/15/5112.aspx"&gt;This guy knew the answer if I had read my opened tabs.&lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/2831.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">So when trying to read from excel files we got this message repeatedly, and could not figure out what the hell it meant.  We tried reinstalling some dlls that were suggested by other blog posts, but nothing would make the excel file open.  Turns out, our connection string was wrong.  <br /><br />

This is a basic correct connection string.
"Provider=Microsoft.Jet.OleDb.4.0;data source=[FILE_PATH];Extended Properties=Excel 8.0;"
<br /><br />
UPDATE: <a href="http://blogs.wdevs.com/Gaurang/archive/2005/06/15/5112.aspx">This guy knew the answer if I had read my opened tabs.</a><img src ="http://blogs.acceleration.net/russ/aggbug/2831.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Seriously(elipsis) WTF!?!</title><link>http://blogs.acceleration.net/russ/archive/2005/10/13/2791.aspx</link><pubDate>Thu, 13 Oct 2005 14:14:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/10/13/2791.aspx</guid><description>What the hell is wrong with these people?&lt;br /&gt;
&lt;a href="http://www.godhatesfags.com"&gt;&lt;img src="http://blogs.acceleration.net//images/blogs_acceleration_net/russ/42/r_WhatTheHell.jpg" /&gt;&lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/2791.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">What the hell is wrong with these people?<br />
<a href="http://www.godhatesfags.com"><img src="http://blogs.acceleration.net//images/blogs_acceleration_net/russ/42/r_WhatTheHell.jpg" /></a><img src ="http://blogs.acceleration.net/russ/aggbug/2791.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>IE6 Error downloading PDFs over SSL</title><link>http://blogs.acceleration.net/russ/archive/2005/10/12/2788.aspx</link><pubDate>Wed, 12 Oct 2005 17:03:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/10/12/2788.aspx</guid><description>&lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;323308"&gt;This MS page descibes the error.&lt;/a&gt; One thing they dont mention is a solution.  They do say that:&lt;br /&gt;&lt;br /&gt;

&lt;b&gt;CAUSE&lt;/b&gt;&lt;br /&gt;
This issue occurs if the server sends a "Cache-control:no-store" header or sends a "Cache-control:no-cache" header.&lt;br /&gt;
&lt;i&gt; What they dont mention is that it isnt only the "Cache-contol" header; the "Pragma:no-cache" header also causes this problem. &lt;/i&gt;

&lt;br /&gt;&lt;br /&gt;

&lt;b&gt;A SOLUTION&lt;/b&gt;&lt;br /&gt;
Remove all of these headers, and make sure that you have the following headers set:&lt;br /&gt;
  Response.AddHeader("Pragma","private");&lt;br /&gt;
  Response.AddHeader("Cache-control","private, must-revalidate");&lt;br /&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/2788.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;323308">This MS page descibes the error.</a> One thing they dont mention is a solution.  They do say that:<br /><br />

<b>CAUSE</b><br />
This issue occurs if the server sends a "Cache-control:no-store" header or sends a "Cache-control:no-cache" header.<br />
<i> What they dont mention is that it isnt only the "Cache-contol" header; the "Pragma:no-cache" header also causes this problem. </i>

<br /><br />

<b>A SOLUTION</b><br />
Remove all of these headers, and make sure that you have the following headers set:<br />
  Response.AddHeader("Pragma","private");<br />
  Response.AddHeader("Cache-control","private, must-revalidate");<br /><img src ="http://blogs.acceleration.net/russ/aggbug/2788.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>IE bug in dynamically added select options</title><link>http://blogs.acceleration.net/russ/archive/2005/07/27/1849.aspx</link><pubDate>Wed, 27 Jul 2005 17:16:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/27/1849.aspx</guid><description>If you add options to a select dynamically via javascript, IE will not render this correctly until you have opened and closed the select menu a few time.  To get around this you just need to remove the select from the DOM then add it back.  Setting the innerHTML will not help things :(  Unfortunatly, setting the innerHTML causes bugs in both major browsers.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1849.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">If you add options to a select dynamically via javascript, IE will not render this correctly until you have opened and closed the select menu a few time.  To get around this you just need to remove the select from the DOM then add it back.  Setting the innerHTML will not help things :(  Unfortunatly, setting the innerHTML causes bugs in both major browsers.<img src ="http://blogs.acceleration.net/russ/aggbug/1849.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Oh Spider Monkey why doest thou keep secrets from me</title><link>http://blogs.acceleration.net/russ/archive/2005/07/21/1834.aspx</link><pubDate>Thu, 21 Jul 2005 17:46:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/21/1834.aspx</guid><description>There are so many hidden things inside of the javascript implementations that it is a constant frustration.  I happen to like javascript an awful lot, but damn this language/environment for being so fickle.
&lt;br /&gt;&lt;br /&gt;
The magic functions/properties I found are listed below.  They solve one of my biggest problems with the javascript getter/setter system that &lt;a title="Birdman" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; &lt;a href="http://blogs.acceleration.net/birdman/archive/2005/04/28/1055.aspx"&gt;wrote about here&lt;/a&gt;, which is that by doing what &lt;a title="Birdman" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; was doing, we couldn't find a way to get a reference to the actual function doing the getting/setting.  I really hate that these are totally hidden.
&lt;br /&gt;&lt;br /&gt;
__proto__ : a reference to the current instances prototype (deprecated in Rhino)&lt;br /&gt;
__defineGetter__('propName', func) :  creates a getter function with the name provided as the first argument&lt;br /&gt;
__defineSetter__('propName', func) :  creates a Setter function with the name provided as the first argument&lt;br /&gt;
__lookupGetter__('propName') :  gets a reference to the getter function of a given property (whose name is passed as an argument)&lt;br /&gt;
__lookupSetter__('propName') :  gets a reference to the setter function of a given property (whose name is passed as an argument)&lt;br /&gt;
&lt;br /&gt;
__parent__ seems to return the scope that something is defined in, but we cant really get this to do anything reliably and its also deprecated.  &lt;a title="Birdman" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; seems to think that this is what a closure uses to keep track of its scope.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1834.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">There are so many hidden things inside of the javascript implementations that it is a constant frustration.  I happen to like javascript an awful lot, but damn this language/environment for being so fickle.
<br /><br />
The magic functions/properties I found are listed below.  They solve one of my biggest problems with the javascript getter/setter system that <a title="Birdman" href="http://blogs.acceleration.net/birdman/">Nathan</a> <a href="http://blogs.acceleration.net/birdman/archive/2005/04/28/1055.aspx">wrote about here</a>, which is that by doing what <a title="Birdman" href="http://blogs.acceleration.net/birdman/">Nathan</a> was doing, we couldn't find a way to get a reference to the actual function doing the getting/setting.  I really hate that these are totally hidden.
<br /><br />
__proto__ : a reference to the current instances prototype (deprecated in Rhino)<br />
__defineGetter__('propName', func) :  creates a getter function with the name provided as the first argument<br />
__defineSetter__('propName', func) :  creates a Setter function with the name provided as the first argument<br />
__lookupGetter__('propName') :  gets a reference to the getter function of a given property (whose name is passed as an argument)<br />
__lookupSetter__('propName') :  gets a reference to the setter function of a given property (whose name is passed as an argument)<br />
<br />
__parent__ seems to return the scope that something is defined in, but we cant really get this to do anything reliably and its also deprecated.  <a title="Birdman" href="http://blogs.acceleration.net/birdman/">Nathan</a> seems to think that this is what a closure uses to keep track of its scope.<img src ="http://blogs.acceleration.net/russ/aggbug/1834.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Object Keyed Hashtable in Javascript</title><link>http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx</link><pubDate>Wed, 06 Jul 2005 19:50:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx</guid><description>

In the last couple days I have had the need to put keys (that are objects) into a hashtable. Since the default js hashtable only allows string keys (see &lt;a href="http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx"&gt;my last post on this topic&lt;/a&gt;), I decided to check the internet.  &lt;a href="http://m.synovic.home.att.net/hashtable/hashtable.html"&gt;Synovic &lt;/a&gt; is most highly rated by google, and pretty much every other refernce to javascript hashtable points to either his implementation or notes that {key:value}  creates an object/array/hashtable in javascript.  Because Synovic's hashtable is just a java like wrapper around the default hashtable, his suffers from the same built in flaw that the normal hashtable suffers.  I seem to be the only one with the need to hash based off objects.  One of the requirements I had was that I didnt want to modify the key (which would greatly simplify the problem).  If I could just add a hashcode to every object passed in as a key this whole problem again becomes trivial.  The only problem is that, since objects == hashtable in javascript, I could be accidently adding things to a collection that I dont want to be modified.  Also it just seems like a horrible practice to have random functions adding properties to your objects.   My solution was basically to create a hash code that I could use to identify objects.  Then, using that hashcode, I look into an internal string-keyed hashtable.  In that value slot,  I store an array of {key: objectKey, value: valPassedIn} objects.  Then it is linear look up to go through the array.  If I can improve the Hashcode function I can improve the overall performance of my Hashtable object, but right now I havn't a clue how to do this.

and now, the moment youve all been waiting for:
&lt;h2&gt;&lt;a href="http://blogs.acceleration.net/russ/articles/1743.aspx"&gt;Hashtable Source&lt;/a&gt;&lt;/h2&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1744.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">

In the last couple days I have had the need to put keys (that are objects) into a hashtable. Since the default js hashtable only allows string keys (see <a href="http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx">my last post on this topic</a>), I decided to check the internet.  <a href="http://m.synovic.home.att.net/hashtable/hashtable.html">Synovic </a> is most highly rated by google, and pretty much every other refernce to javascript hashtable points to either his implementation or notes that {key:value}  creates an object/array/hashtable in javascript.  Because Synovic's hashtable is just a java like wrapper around the default hashtable, his suffers from the same built in flaw that the normal hashtable suffers.  I seem to be the only one with the need to hash based off objects.  One of the requirements I had was that I didnt want to modify the key (which would greatly simplify the problem).  If I could just add a hashcode to every object passed in as a key this whole problem again becomes trivial.  The only problem is that, since objects == hashtable in javascript, I could be accidently adding things to a collection that I dont want to be modified.  Also it just seems like a horrible practice to have random functions adding properties to your objects.   My solution was basically to create a hash code that I could use to identify objects.  Then, using that hashcode, I look into an internal string-keyed hashtable.  In that value slot,  I store an array of {key: objectKey, value: valPassedIn} objects.  Then it is linear look up to go through the array.  If I can improve the Hashcode function I can improve the overall performance of my Hashtable object, but right now I havn't a clue how to do this.

and now, the moment youve all been waiting for:
<h2><a href="http://blogs.acceleration.net/russ/articles/1743.aspx">Hashtable Source</a></h2><img src ="http://blogs.acceleration.net/russ/aggbug/1744.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Javascript Hashtable</title><link>http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx</link><pubDate>Tue, 05 Jul 2005 16:23:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx</guid><description>First, I recognize that an Array is an Object is an Hashtable in javascript.  The problem is that only strings can act as a key in an Object.  
Meaning:
&lt;pre&gt;
 var x = new Object()  
 var y = new Object()  
&lt;i&gt;&amp;gt;&amp;gt; [object Object] &lt;/i&gt;
 z = new Object()  
&lt;i&gt;&amp;gt;&amp;gt; [object Object] &lt;/i&gt;
 x[y] = 'test' ;
&lt;i&gt;&amp;gt;&amp;gt; test&lt;/i&gt;
 x[z]  
&lt;i&gt;&amp;gt;&amp;gt; test &lt;/i&gt;
&lt;/pre&gt;

Since alot of the objects in javascript return [Object] as their toString(), this means that I cannot key a hashtable off objects.  I guess I'll get to work writing an actual Hashtable instead of just relying on the built in stuff.  I will post this when I am done.  For now, off to class.
&lt;br /&gt;&lt;br /&gt;
UPDATE: &lt;a href="http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx"&gt; The Exciting Conclusion &lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1736.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">First, I recognize that an Array is an Object is an Hashtable in javascript.  The problem is that only strings can act as a key in an Object.  
Meaning:
<pre>
 var x = new Object()  
 var y = new Object()  
<i>&gt;&gt; [object Object] </i>
 z = new Object()  
<i>&gt;&gt; [object Object] </i>
 x[y] = 'test' ;
<i>&gt;&gt; test</i>
 x[z]  
<i>&gt;&gt; test </i>
</pre>

Since alot of the objects in javascript return [Object] as their toString(), this means that I cannot key a hashtable off objects.  I guess I'll get to work writing an actual Hashtable instead of just relying on the built in stuff.  I will post this when I am done.  For now, off to class.
<br /><br />
UPDATE: <a href="http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx"> The Exciting Conclusion </a><img src ="http://blogs.acceleration.net/russ/aggbug/1736.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>The XBL Template / Repeater control</title><link>http://blogs.acceleration.net/russ/archive/2005/04/10/819.aspx</link><pubDate>Sun, 10 Apr 2005 17:04:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/04/10/819.aspx</guid><description>So I finally found a palatable solution to the &lt;a href="http://blogs.acceleration.net/russ/archive/2005/04/06/804.aspx"&gt;Templates Problem&lt;/a&gt; I talked about earlier.  The technique I used was to create a XBL control called 'repeater'.  &lt;a title="Ryan" href="http://blogs.acceleration.net/ryan/"&gt;Ryan&lt;/a&gt; had some issues with the word template as I was using it so we switched over to repeater to be less ambiguous.  The goal of this is not to provide a general control system (which XBL and &lt;a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank"&gt;XBLinJS&lt;/a&gt; try to do), but only to provide the functionality to easily repeat nodes inside of a valid tag.  The best example I can give for this is for  binding a dropdownlist / select box / menupopup, where I just need to repeat the &amp;lt;menuitem /&amp;gt; over a flat set of data.  
&lt;br /&gt;&lt;br /&gt;
var testTable = [['id', 'name'],&lt;br /&gt;
 [ 1, 'Programmers' ],&lt;br /&gt;
 [ 2, 'WebAdmin' ],&lt;br /&gt;
 [ 3, 'Broadband']];&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hbox&amp;gt;&lt;br /&gt;
  &amp;lt;repeater&amp;gt;&lt;br /&gt;
    &amp;lt;label value="{name}" /&amp;gt;&lt;br /&gt;
  &amp;lt;/repeater&amp;gt;&lt;br /&gt;
&amp;lt;/hbox&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What the 'repeater' control does is remove the repeater node from its parent storing a reference to this 'template' on that control (so we have what was there but none of it is rendered).  Then it loops through the data set adding all of the nodes that were inside of the repeater tags, with their values filled in.  So what gets rendered to the page would be this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hbox&amp;gt;&lt;br /&gt;
    &amp;lt;label value="Programmers" /&amp;gt;&lt;br /&gt;
    &amp;lt;label value="WebAdmin" /&amp;gt;&lt;br /&gt;
    &amp;lt;label value="Broadband" /&amp;gt;&lt;br /&gt;
&amp;lt;/hbox&amp;gt;&lt;br /&gt;
&lt;br /&gt;

The really nice part about this system is that by inserting a repeater node inside of the template, with the outer template filling in the datasource attribute for the inner repeater as it goes, allows you to chain these repeaters to make hierarchical data repeaters.   After I finish polishing everything and test it once more, I am going to port this to use &amp;lt;div repeater="true" &amp;gt; [enter repeated data here]&amp;lt;/div&amp;gt; so that I can achieve the same repeater functionality in standard HTML.   
&lt;br /&gt;&lt;br /&gt;
Overall this has been my best experience with XBL, most notable because it required only one function block and one line of xbl content binding  ( the &amp;lt;children /&amp;gt; node).  It did however force me to copy code in and out of the xbl document to a standard JS doc to get parse errors to show up (Mozilla was just silently failing when their was a parse error in the XBL Javascript). 
&lt;br /&gt;&lt;br /&gt;
&lt;a title="Ryan" href="http://blogs.acceleration.net/ryan/"&gt;Ryan&lt;/a&gt; will probably give us a little preview of his js control scheme based of his interpretations of &lt;a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank"&gt;XBLinJS&lt;/a&gt;.  What it seems we've got almost worked out is a simple way to repeat nodes and a simple way to create complex, repeatable, XUL/HTML controls.  Most of this work was inspired by excessive frustration (mostly caused by nonexistant error handling) at the way mozilla handles these two things  and by reading &lt;a href="http://www.jerf.org"&gt;Jeremy Bowers&lt;/a&gt; site which convinced us to do what we already wanted to do.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
UPDATE:&lt;br /&gt;
&lt;a href="http://blogs.acceleration.net/russ/articles/1062.aspx"&gt;Go Here to see  the Repeater Source&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://blogs.acceleration.net/russ/articles/1145.aspx"&gt;Usage Example&lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/819.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">So I finally found a palatable solution to the <a href="http://blogs.acceleration.net/russ/archive/2005/04/06/804.aspx">Templates Problem</a> I talked about earlier.  The technique I used was to create a XBL control called 'repeater'.  <a title="Ryan" href="http://blogs.acceleration.net/ryan/">Ryan</a> had some issues with the word template as I was using it so we switched over to repeater to be less ambiguous.  The goal of this is not to provide a general control system (which XBL and <a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank">XBLinJS</a> try to do), but only to provide the functionality to easily repeat nodes inside of a valid tag.  The best example I can give for this is for  binding a dropdownlist / select box / menupopup, where I just need to repeat the &lt;menuitem /&gt; over a flat set of data.  
<br /><br />
var testTable = [['id', 'name'],<br />
 [ 1, 'Programmers' ],<br />
 [ 2, 'WebAdmin' ],<br />
 [ 3, 'Broadband']];<br />
<br />
&lt;hbox&gt;<br />
  &lt;repeater&gt;<br />
    &lt;label value="{name}" /&gt;<br />
  &lt;/repeater&gt;<br />
&lt;/hbox&gt;<br />
<br />
What the 'repeater' control does is remove the repeater node from its parent storing a reference to this 'template' on that control (so we have what was there but none of it is rendered).  Then it loops through the data set adding all of the nodes that were inside of the repeater tags, with their values filled in.  So what gets rendered to the page would be this:<br />
<br />
&lt;hbox&gt;<br />
    &lt;label value="Programmers" /&gt;<br />
    &lt;label value="WebAdmin" /&gt;<br />
    &lt;label value="Broadband" /&gt;<br />
&lt;/hbox&gt;<br />
<br />

The really nice part about this system is that by inserting a repeater node inside of the template, with the outer template filling in the datasource attribute for the inner repeater as it goes, allows you to chain these repeaters to make hierarchical data repeaters.   After I finish polishing everything and test it once more, I am going to port this to use &lt;div repeater="true" &gt; [enter repeated data here]&lt;/div&gt; so that I can achieve the same repeater functionality in standard HTML.   
<br /><br />
Overall this has been my best experience with XBL, most notable because it required only one function block and one line of xbl content binding  ( the &lt;children /&gt; node).  It did however force me to copy code in and out of the xbl document to a standard JS doc to get parse errors to show up (Mozilla was just silently failing when their was a parse error in the XBL Javascript). 
<br /><br />
<a title="Ryan" href="http://blogs.acceleration.net/ryan/">Ryan</a> will probably give us a little preview of his js control scheme based of his interpretations of <a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank">XBLinJS</a>.  What it seems we've got almost worked out is a simple way to repeat nodes and a simple way to create complex, repeatable, XUL/HTML controls.  Most of this work was inspired by excessive frustration (mostly caused by nonexistant error handling) at the way mozilla handles these two things  and by reading <a href="http://www.jerf.org">Jeremy Bowers</a> site which convinced us to do what we already wanted to do.<br /><br /><br />
UPDATE:<br />
<a href="http://blogs.acceleration.net/russ/articles/1062.aspx">Go Here to see  the Repeater Source</a><br />
<a href="http://blogs.acceleration.net/russ/articles/1145.aspx">Usage Example</a><img src ="http://blogs.acceleration.net/russ/aggbug/819.aspx" width = "1" height = "1" /></body></item></channel></rss>