<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-26602852</atom:id><lastBuildDate>Wed, 10 Mar 2010 09:43:40 +0000</lastBuildDate><title>Robs Programming Junk</title><description>Welcome to my programming blog.  This Blog contains my research and notes pertaining to programming. You are free to use any information on this site however you must make a comment on the blog, and put credit in your code that you obtained it from here. You can contact me directly at rob @at@ robsprogrammingjunk.com.</description><link>http://www.robsprogrammingjunk.com/</link><managingEditor>noreply@blogger.com (Rob)</managingEditor><generator>Blogger</generator><openSearch:totalResults>69</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-8683263556438735848</guid><pubDate>Tue, 05 Jan 2010 17:34:00 +0000</pubDate><atom:updated>2010-01-24T07:14:57.703-08:00</atom:updated><title>Aptana, FTP, WebDav, PDT and Eclipse - Why cant FTP be easy?</title><description>&lt;span class="Apple-style-span"   style="  border-collapse: collapse; font-family:arial, sans-serif;font-size:13px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="  border-collapse: collapse; font-family:arial, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;I've used Aptana now for quite some time and I was disappointed to hear they were discontinuing PHP development.  Not surprising considering the PDT acceptance and integration from everything from Eclipse to Zend as the primary PHP development toolkit.  The &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;huge&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; hassle for me was that the &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;FTP and WebDav&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; plugins for Eclipse are useless from a web developer perspective.  Frequently I'm challenged with small modifications to existing sites and uploading and downloading with other tools or "importing" and exporting is unrealistic.  I would spend more time and effort in setting up a project than making some of the changes on a clients website.  This also doesn't address the issues surrounding a team environment where you might need to sync back and forth on the same FTP server with multiple users.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class="Apple-style-span"  style="  border-collapse: collapse; font-family:arial, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;So, after much hassle with Aptana, Eclipse and PHP I figured out how to have everything I need for development.  This allows me to continue to use Aptana's FTP/SFTP plugins, JavaScript and jQuery tools as well as use PDT as the development IDE.  This also enabled me to use other eclipse plugins I liked the &lt;/span&gt;&lt;a href="http://www.jcraft.com/eclipse-sftp/"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;SFTP Plugin&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; which I couldn't get installed in Aptana's standalone version.  So here is the process for getting everything you had in Aptana 1.5 working with Aptana 2.0&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Step 1.  Download and install &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;a href="http://www.eclipse.org/downloads/"&gt;Eclipse PHP Tools &lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;a href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR1/eclipse-php-galileo-SR1-linux-gtk.tar.gz" target="_blank" style="color: rgb(87, 151, 176); "&gt;&lt;/a&gt;Step 2. Add Eclipse as a new site and install it as a plugin to Eclipse &lt;/span&gt;&lt;a href="http://www.aptana.org/studio/plugin" target="_blank" style="color: rgb(87, 151, 176); "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;http://www.aptana.org/studio/plugin&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; This will require a restart of the IDE.&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Step 3. After that is complete, go to Window -&amp;gt; My Studio, Click the plugins graphic.  Using the Ajax Tab, find Jquery, and click Get It.  This runs the update manager, you'll need to select jQuery in the list of ajax plugins.  You can optionally install all, but jquery is the only framework I generally use.  Restart of IDE Required&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Step 4. Window -&amp;gt; Open Perspective, choose Aptana Web&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;You should then be able to use the file manager to create FTP connections and continue as before.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; Apatana folks really need to make this part of the FAQ.  &lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-8683263556438735848?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2010/01/aptana-ftp-webdav-pdt-and-eclipse-why.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1269116425951284931</guid><pubDate>Thu, 23 Jul 2009 18:17:00 +0000</pubDate><atom:updated>2009-07-23T12:26:11.917-07:00</atom:updated><title>Dynamic Query Parameters for Jasper Reports</title><description>Recently I've been working with Jasper Reports.  I don't often do a lot of report writing so I enjoyed the opportunity to work on something different.  &lt;br /&gt;&lt;br /&gt;Once I had a query full of data I began to use the Jasper Parameters to filter out items in my query.  For example I might have a query that looks like this.&lt;br /&gt;&lt;br /&gt;select * from employees where first='$P{first_name}' and last='$P{last_name)'&lt;br /&gt;&lt;br /&gt;Really simple stuff here nothing that Jasper didn't do or support.  So I of course took this to the next level and said ok, I'm just looking for a last name so lets put in just the last name, leave the first name blank.  Well when I did that the whole thing blew up because I had a query that looked like this at runtime&lt;br /&gt;&lt;br /&gt;select * from employees where first='' and last='Smith'&lt;br /&gt;&lt;br /&gt;So I have to put a parameter in?  That's ridiculous! Searching around the meager JasperReports documentation I couldn't find anything helpful either.  Checking with co-workers who use this more than I do I found that most of the time they build SQL in a stored procedure for this.  I'm not opposed to a stored procedure but when you just want to filter a few things it's really stupid to have to jump through those kind of hoops.&lt;br /&gt;&lt;br /&gt;I came up with a elegant solution to this that I could do within iReport and with no extra classes (as jasper suggests using a scriptlet - which isnt really a script its a java class).&lt;br /&gt;&lt;br /&gt;The solution was quite simple once I figured it out.  I created the regular parameter for input.  This would be first_name, I then created a second parameter (not for input) called first_name_value.  Inside the first_name_value "Default Value Expression" I entered this java code:&lt;br /&gt;&lt;br /&gt;($P{first_name}.isEmpty()==true ? "" : " and first='" + $P{first_name} +"'" )&lt;br /&gt;&lt;br /&gt;Now, once I had that inside my SQL code I used the following&lt;br /&gt;&lt;br /&gt;select * from employees where last='$P{last_name)' $P!{first_name_value}&lt;br /&gt;&lt;br /&gt;What this does is output NOTHING if first_name is blank.  If it is filled with a value we add the entire "and first='John'" at runtime into the SQL statement.  This of course has the drawback that you have to have at least 1 qualifier in your sql statement.  Try something like where last!='' as a default.  This then gives you every row and any "and" clauses are appended to the end.  Also notice the $P! with the ! in there.  That means it will evaluate before the query.&lt;br /&gt;&lt;br /&gt;Why not just use a stored procedure?  Well a couple of reasons.  First, SP's take time.  Sure, you might be good at them and can get your SP written in a short amount of time.  Go for it.  This solution works well because you don't have to bother with an SP at all.  A simple query can be done within iReport and these filters applied.&lt;br /&gt;&lt;br /&gt;Get fancy.  You could get fancy with this and use your expression code to handle replacements as well.  For example you could allow a &gt; 95 and change the code to remove the = sign if something like that is input.  &lt;br /&gt;&lt;br /&gt;Hope this helps in your report development.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1269116425951284931?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/07/dynamic-query-parameters-for-jasper.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>8</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1682031522933401049</guid><pubDate>Fri, 08 May 2009 15:14:00 +0000</pubDate><atom:updated>2009-05-08T08:24:15.549-07:00</atom:updated><title>IE8 Developer Tools</title><description>I have never been a fan of IE8.  Most serious developers (web or otherwise) know that it is rubbish that unfortuneately has a very large adoption.  I generally do most of my web development in &lt;a href="http://www.mozilla.com/firefox/"&gt;FireFox&lt;/a&gt; and use &lt;a href="http://www.getfirebug.com/"&gt;Fire Bug&lt;/a&gt; to do my web site debugging and design.  I like of course the on-the-fly features of changing and prototyping different web layouts.&lt;br /&gt;&lt;br /&gt;IE has always been a pain my side not only because of their refusal to adopt widely used DOM standards but buggy browsers that are impossible to reasonably debug.  &lt;br /&gt;&lt;br /&gt;Today I needed to verify a layout issue and with my recent IE8 upgrade noticed the developers tools in the menu.  I nearly fell out of my chair in shock to see a robust set of developer tools.  This was just amazing that I could now do nearly the same things I could do in Fire Bug.  I am in no way going to ditch firebug but I now have a rather decent means to debug IE problems specifically.&lt;br /&gt;&lt;br /&gt;I could use Fire Bug Lite but I find that it's performance is poor in IE.  This does work well however.  I imagine that Microsoft is trying to muscle-in on the developer market but I think most serious developers are going to do ground-up development in FireFox.&lt;br /&gt;&lt;br /&gt;Chrome is still my favorite browser to surf in.  I can't wait till they get the developer tools in it so I can use it for more web development.&lt;br /&gt;&lt;br /&gt;Anyhow, IE8 gained a few (very few) points with me today since they finally got some developer tools that actually work.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1682031522933401049?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/05/ie8-developer-tools.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-520837291356017639</guid><pubDate>Sat, 18 Apr 2009 21:31:00 +0000</pubDate><atom:updated>2009-04-18T14:39:24.033-07:00</atom:updated><title>Portable Ubuntu - Take Linux With You</title><description>I have to admit that I first thought that portable Ubuntu was going to be a install on a flash drive.  It actually runs UNDER windows.  The real credit though goes to &lt;a href="http://www.colinux.org/"&gt;Cooperative Linux&lt;/a&gt;.  This allows a linux distro (almost any) to run while windows is running.  Now I took the easy route and ran Ubuntu which is a decent distro for most desktop users.  &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Performance&lt;/b&gt;&lt;br /&gt;It ran sluggish at first.  I was really kind of disappointed and thought that it was because it was running from the flash drive.  It really was just not getting enough CPU.  I was able to improve the experience considerably on my laptop by setting the colinux and associated exe's to a high priority.  This allowed them to get a bit more task scheduling from windows.  This was enough to kill the little bit of sluggishness and get me rocking with all that linux has to offer.&lt;br /&gt;&lt;br /&gt;On a side note this isnt my first experience with linux or ubuntu.  I've run it under VM's and dedicated boxes for some time.  It is just very nice to be able to start it up, shut it down and run it while I'm running windows apps.  I'm going to go download aptana for linux and try it out under there.  Would be nice to be able to take my favorite IDE everywhere regardless of the PC I'm on.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-520837291356017639?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/04/portable-ubuntu-take-linux-with-you.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-4837593458802025866</guid><pubDate>Thu, 09 Apr 2009 18:18:00 +0000</pubDate><atom:updated>2009-04-09T11:23:14.057-07:00</atom:updated><title>Quote Curling Function</title><description>I recently had to add some curly quotes to text on the page.  The following function allows you to add Microsoft Word Style Curly Quotes in replacement of standard quotes.  Uses some basic regex to accomplish this quickly and easily.  &lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="php"&gt;&lt;br /&gt;echo curlQuotes('"This" is a "test", a great "test" I think. Don\'t you?');&lt;br /&gt;&lt;br /&gt;// Curl Quote Function rob@mechsoftware.com&lt;br /&gt;function curlQuotes($curlme) {&lt;br /&gt; // Adds fancy Microsoft Word Style Quotes to standard text.&lt;br /&gt; $curlme = preg_replace('/(.+)"(.+)"(.+)/Ss',"$1&amp;#8220;$2&amp;#8221;$3",$curlme);&lt;br /&gt; $curlme = preg_replace('/(.+)"(.+)"/Ss',"$1&amp;#8220;$2&amp;#8221;",$curlme);&lt;br /&gt; $curlme = preg_replace('/"(.+)"(.+)/Ss',"&amp;#8220;$1&amp;#8221;$2",$curlme);&lt;br /&gt; $curlme = str_replace("'",'&amp;#8217;',$curlme); &lt;br /&gt; return $curlme;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Output is:&lt;br /&gt;&lt;br /&gt;&amp;#8220;This&amp;#8221; is a &amp;#8220;test&amp;#8221;, a great &amp;#8220;test&amp;#8221; I think. Don&amp;#8217;t you?&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-4837593458802025866?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/04/quote-curling-function.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-4843878042967551873</guid><pubDate>Mon, 16 Feb 2009 14:55:00 +0000</pubDate><atom:updated>2009-02-16T06:58:09.781-08:00</atom:updated><title>Same Blog, New Look</title><description>You have to be blind not to notice the new look on my blog. It now matches the www.mechsoftware.com look and feel for a uniform look across my sites.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-4843878042967551873?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/02/same-blog-new-look.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1675291598727079424</guid><pubDate>Fri, 23 Jan 2009 21:33:00 +0000</pubDate><atom:updated>2009-01-23T13:47:11.457-08:00</atom:updated><title>On the fly JavaScript Packing - Speed up your site!</title><description>&lt;a href="http://developer.yahoo.com/performance/rules.html#minify"&gt;Minification of javascript has many benefits.&lt;/a&gt;  One thing that is a pain for developers is remembering to pack your javascript before deployment.  Another big pain is if you need to do an on-server change of some JavaScript code.  Using &lt;a href="http://joliclic.free.fr/php/javascript-packer/en/"&gt;Packer JavaScript en PHP&lt;/a&gt; a small PHP file and a tweak to .htaccess you can minify your JavaScript on the fly and never again have to worry about minifying your javascript.  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First, download the &lt;a href="http://joliclic.free.fr/php/javascript-packer/en/"&gt;Packer JavaScript en PHP&lt;/a&gt; and extract class.JavaScriptPacker.php to some location on your server.  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now create a .PHP file with the following code.&lt;br /&gt;&lt;textarea name="codeblock" class="php"&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;require 'class.JavaScriptPacker.php';&lt;br /&gt;if(substr($_REQUEST['js'],0,1)=="/")&lt;br /&gt;  $_REQUEST['js']=substr($_REQUEST['js'],1);&lt;br /&gt;$script = file_get_contents($_REQUEST['js']);&lt;br /&gt;&lt;br /&gt;$packer = new JavaScriptPacker($script, 'Normal', true, false);&lt;br /&gt;$packed = $packer-&gt;pack();&lt;br /&gt;&lt;br /&gt;echo $packed;&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next, bust open the .htaccess and add the following.  Note you should have mod_rewrite enabled and mod_rewrite set to ON.  If you dont know how to do this, contact your sysadmin or check it out on apache's website.&lt;br /&gt;&lt;textarea name="codeblock" class="html"&gt;&lt;br /&gt;RewriteRule ^(.+)\.js$ jsProxy.php?js=/$1.js&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, the concept here is pretty simple.  You take any .js javascript file and route it through the proxy.  Once the proxy gets it, the packer compresses it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Need to exclude a file? Simply make it .jsx or some other extension other than .js, the browser doesn't care but mod_rewrite will ignore it.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1675291598727079424?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/on-fly-javascript-packing-speed-up-your.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-8258804849709082197</guid><pubDate>Thu, 22 Jan 2009 08:00:00 +0000</pubDate><atom:updated>2009-01-22T00:00:01.834-08:00</atom:updated><title>Super Simple AJAX Forms with jQuery and JSON : dataservice.php</title><description>Our last installment of the Super Simple AJAX Forms with jQuery and JSON we cover the server side of things.  The dataservice.php file covers the business logic behind the web form.  Like the webpage.html I boiled this down to the smallest and most reusable code possible.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The very top of the file contains MySQL setup code for connecting to the database.  If this is not familiar by now then this tutorial is probably a bit over your head anyhow.  In any case set that up, i'm not going to cover it in detail here.  Let's get to the meat of our discussion.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;PHP Parameters&lt;br /&gt;&lt;textarea name="codeblock" class="php"&gt;&lt;br /&gt;// Make sure we have a full Request&lt;br /&gt; if(!isset($_REQUEST['action']) || !isset($_REQUEST['id'])){&lt;br /&gt;  echo "Invalid Request";&lt;br /&gt; exit(0);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;// Which action do we take?  If we dont find one we do nothing.&lt;br /&gt; if($_REQUEST['action']=='getuser')&lt;br /&gt; getUser((int)$_REQUEST['id']);  // sanitize  ID by converting to int&lt;br /&gt; if($_REQUEST['action']=='update')&lt;br /&gt; updateUser((int)$_REQUEST['id']);  // sanitize  ID by converting to int&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;This code is straightforward.  We simply make sure we have our unique key (id) and our action (something to do).  If we do we proceed to map the parameter action to a function we'll call.  We sanitize the ID coming in to prevent SQL injection.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;getUser() function&lt;br /&gt;&lt;textarea name="codeblock" class="php"&gt;&lt;br /&gt;// Get User Method&lt;br /&gt;function getUser($id){&lt;br /&gt;  $query  = "select * from users where uid=".$id;&lt;br /&gt;  $result = mysql_query($query);&lt;br /&gt;  while($row = mysql_fetch_array($result, MYSQL_ASSOC)){&lt;br /&gt;  $records[]= $row; // Push into array all records&lt;br /&gt; }&lt;br /&gt; if(!isset($records))&lt;br /&gt;  echo "[{error:'No Records Found',status:'error'}]";&lt;br /&gt; else&lt;br /&gt;  echo json_encode($records); // Encode everything from SQL&lt;br /&gt;  /*&lt;br /&gt;   * If you dont have php 5, or pear installed on your host&lt;br /&gt;   * check out http://mike.teczno.com/json.html&lt;br /&gt;   */&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;This function is called when we load our webpage.html.  It's called by the jQuery ready() in the HTML.  You can see here, it is a very simple query, then we push the result set into an array.  I do this in the example to show that with JSON you can have multiple row results in the response going back.  That way you can even persist the data locally and re-use it when you need to.  If we have a result set we call json_encode() with our records.  This turns it into JSON that we read with javascript on the browser side.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So really, all we do here is build a JSON string out of our MySQL resultset.  The big key is to understand that this is stored in a JSON array.  You need to get a good understanding of JSON to be effective with this sort of application.  Once you do it all falls in line.  Basically a JSON array is a container of JSON objects.  Check out &lt;a href="http://www.json.org/"&gt;Introducing JSON&lt;/a&gt; for more details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, you may not be on PHP5 which has json_encode() natively.  So I put in here a link to the source code for a JSON encode function.  Pear also has this type of library but depending on your web host situation you may need to fall back on the JSON.php file itself.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;updateUser() function&lt;br /&gt;&lt;textarea name="codeblock" class="php"&gt;&lt;br /&gt;function updateUser($id){&lt;br /&gt; // Build update statement&lt;br /&gt; $sql="";&lt;br /&gt; foreach($_REQUEST as $key =&gt; $value){&lt;br /&gt;   if(strpos($key,"FLD_")!==false){ // Something to post&lt;br /&gt;    $sql.=str_replace("FLD_","",$key)."='".mysql_real_escape_string(stripslashes($value))."', ";&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; $sql="update users set ".substr($sql,0,-2)." where uid=".$id;&lt;br /&gt; // Update&lt;br /&gt; mysql_query($sql);&lt;br /&gt; // Check for an updated record&lt;br /&gt; if(mysql_affected_rows()&gt;0){&lt;br /&gt;  echo "{status: 'OK'}";&lt;br /&gt; }else{&lt;br /&gt;  echo "{status: 'Update Failed '}";&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;Finally, our update statement.  This is as simple as our process for filling the FLD_ in the webpage.html file.  We scan the entire $_REQUEST array for any FLD_ and then post those to our database string.  It works just like how we built our queryString in the webpage.html post.  We set the values to update, then we runs the mysql_query() to update records.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Take note of a few things here.  First we &lt;b&gt;strip off&lt;/b&gt; the FLD_ prefix.  We also sanitize the input data by stripping out slashes and escaping special characters for mysql.  Again this is to prevent SQL injection.  I see many people who don't do this with AJAX services and thus are very open to attack on their back end.  I also pull off the last ", " off the end of the update statement.  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We last check to see we updated a row or we return an error.  The webpage.html code looks for the OK, so if we don't have it then we display the error.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;That is it.  You should be able to use this as an example and start to your own AJAX code.  Remember this is a learning example and that you should make sure you have far better error checking and recovery from SQL errors.  You might also want to adapt this code for an insert statement or a delete statement to have full CRUD updates to your database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My purpose here was to show you that asynchronous web calls are not that complicated with the right library (jQuery).  Now get out there and write some code!&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-8258804849709082197?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/super-simple-ajax-forms-with-jquery-and_22.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7067890369096756918</guid><pubDate>Wed, 21 Jan 2009 14:04:00 +0000</pubDate><atom:updated>2009-01-21T06:44:24.601-08:00</atom:updated><title>Super Simple AJAX Forms with jQuery and JSON : webpage.html</title><description>In this installment of the super simple AJAX forms with jQuery we look at the webpage.html file.  This is a pretty simple HTML file all things considered.  The key components of this HTML file are the &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 0, 0);"&gt;.changed&lt;/span&gt;&lt;/span&gt; style in the header, the form (called testForm) and the block of javascript code at the bottom.  We'll take a look at each of these parts.  You can download the entire set of source code and following along.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;CSS Style&lt;br /&gt;&lt;textarea name="codeblock" class="html"&gt;&lt;br /&gt; &lt;style&gt;&lt;br /&gt;  /* apply specific formatting for changed fields */&lt;br /&gt;  .changed{&lt;br /&gt;   background-color:yellow;&lt;br /&gt;  }&lt;br /&gt; &lt;/style&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: auto;"&gt;The CSS style here outlines the effect applied to the input boxes when they have been changed.  We name it changed so you can clearly see how e apply this style and use it as a flag to determine what changes need to be posted to the server.  This is really a nice feature of this example.  I see far too often entire records updated when just a single field is changed.  That or complex PHP code is used to compare what is currently in the database.  &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;The Form&lt;br /&gt;&lt;textarea name="codeblock" class="html"&gt;&lt;br /&gt; &lt;form id="testForm"&gt;&lt;br /&gt;  name: &lt;input type="text" id="FLD_name" class="inputfield" onchange="$(this).addClass('changed')"&gt;&lt;br /&gt;&lt;br /&gt;  mail: &lt;input type="text" id="FLD_mail" class="inputfield" onchange="$(this).addClass('changed')"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;input type="hidden" id="FLD_uid"&gt;&lt;br /&gt;  &lt;input type="button" onclick="submitChanges('testForm')" value="Submit Changes"&gt;&lt;br /&gt; &lt;/form&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;This form is nothing special for the most part.  The key items to look at here are the ID names contain a FLD_ prefix.  We do this so we can identify in the PHP code which elements are "fields" that need to be processed.  In the PHP code we read ALL the data sent and filter out just what we need.  So having a unique identifier is critical to make sure our posting of data with MySQL doesnt fail.  The onchange attribute is used to apply the "changed" class with jQuery when the field changes.  This means that unless someone changes the data, it won't be flagged as an item to update.  I added an inputfield class here so you can see that you can have multiple CSS classes applied.    The last item to note is that we have an input button with a method call to submitChanges.  We pass the form ID name along with it.  This is done so you can use the same code regardless of the number of forms.  So with this you are not building form specific code, youre writing a very re-usable element.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;The Javascript&lt;br /&gt;&lt;textarea name="codeblock" class="javascript"&gt;&lt;br /&gt;  // Function to handle the submission of changed &lt;br /&gt;  // only fields on the form we want (multiple form support)&lt;br /&gt;  function submitChanges(formName){&lt;br /&gt;   // Build list of changed variables&lt;br /&gt;   var queryString="";&lt;br /&gt;   $('#'+formName+' .changed').each(function(){&lt;br /&gt;    // Add new varialbe for each "Changed" item&lt;br /&gt;    queryString+="&amp;"+this.id+"="+this.value;&lt;br /&gt;   });&lt;br /&gt;   if(queryString==""){&lt;br /&gt;    alert("Nothing changed on the form");&lt;br /&gt;    return;&lt;br /&gt;   }&lt;br /&gt;   queryString+="&amp;id="+$('#FLD_uid').val(); // Add ID number&lt;br /&gt;&lt;br /&gt;   // Send Data, get reply&lt;br /&gt;   $.getJSON("dataservice.php?action=update"+queryString,function(data){&lt;br /&gt;    // Display Message on errors&lt;br /&gt;    if(data.status!="OK"){&lt;br /&gt;     alert(data.status);&lt;br /&gt;    }else{&lt;br /&gt;     // Remove Changed Attribute on success&lt;br /&gt;     $('#'+formName+' .changed').each(function(){&lt;br /&gt;      $('#'+this.id).removeClass('changed');&lt;br /&gt;     });&lt;br /&gt;    }&lt;br /&gt;   });&lt;br /&gt;  }&lt;br /&gt;  // Sample, get 1 row of data from database&lt;br /&gt;  $(document).ready(function(){&lt;br /&gt;   $.getJSON("dataservice.php?action=getuser&amp;id=2",function(data){&lt;br /&gt;    // find fields we have data for, regardless of form.&lt;br /&gt;    for(var key in data[0]){&lt;br /&gt;         $('#FLD_'+key).val(eval('data[0].'+key));&lt;br /&gt;       }&lt;br /&gt;   });&lt;br /&gt;  });&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;Finally this is where all the work is done.  It is not a large amount of code so it should be easy to follow along.  There are 2 items here.  The first is "submitChanges" the second is the jQuery "ready()" function.  We'll talk about the $(document).ready() at the bottom first.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;Once the page loads, jQuery fires a ready method to run some code.  We use jQuery $.getJSON to talk to our dataservice.php and pull down 1 record from our users database.  You can see here we pass an action of "getuser", and the "id" of 2 which matches the id number in the database.  You'll see this is clear by looking at the dataservice.php.  &lt;br /&gt;&lt;br /&gt;Once we pull this data down, we iterate the "keys" of the JSON data, then using javascript eval() function, we grab the data and post it to any &lt;b&gt;matching&lt;/b&gt; #FLD_&lt;key&gt; on the form.  So for example, if the JSON contains a "name" key {name:'Smith'} in the JSON, we map it to #FLD_name.  We do this for a few reasons.  First, we introduce some logical consistency into how we use our database.  This pulls down a database field name, and we use the same field name in our form.  We get away from problems like a database field called first_name and a form field name called userFirstName.  Later on you'll thank yourself in keeping things consistent and searchable.  We also do this to save time mapping data.  Since we use the same name (with just a prefix added) its easy to do this programatically vs. having to do a lot of formField=dataFieldValue in the code.  Less code for everyone.  So this function is pretty simple, pull down the data, map it into the input fields by name.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: auto;"&gt;&lt;br /&gt;Now we move onto the submitChanges method.  Really, this looks more daunting that it really is.  There is a very limited amount of code here I commented it well so you can see just what you would want to change in your own application&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We first set an empty queryString which will be used to send the changed data to the dataservice.php.  We next tell jQuery to find all the .changed class items in the particular form we just passed.  If that code is a little unclear here is what the expression would look like hardcoded.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 0, 0);"&gt;$('#testForm .changed').each()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, lets just talk about what we asked jQuery to iterate through.  We said find the ID "testForm" then, find all tags with the "changed" CSS class applied. Then, we ask jQuery to iterate through it with the .each() function.  This exposes each tag to us one at a time so we can use it to build our queryString.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;queryString is built, or it's not based on each changed item.  We pull out the FLD_ names of changed data, apply it to the queryString forming something like&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 0, 0);"&gt;&amp;FLD_name=smith&amp;FLD_mail=email@domain.com&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Should we not have any changed data, queryString wont have anything in it and we'll tell the user that nothing changed on the form.  If data changes do need to be posted we skip that IF statement, add the "id" of the record manually and prepare for our posting back to dataservice.php.  &lt;b&gt;NOTE:&lt;/b&gt; The ID is the only hard coded field form element.  "FLD_uid" is a unique key in the database that allows you to map it back to the right element.  You don't necessarily have to do it this way.  Alternatively you could hard code "changed" as a class to it, and it would always be picked up.  The down side to this is that if there is no changed data you'll fire an empty query.  I also like hard coding the ID number because as a primary key of a DB you should always have it. This type of code ensures I don't forget it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next, we call our $.getJSON again, we tell it the action is to update, and append on our queryString.  This is posted to the server and we wait for the response asynchronously. Once we receive it, if it's not OK we return the server message.  Finally if everythig is good, we pull off all the "changed" values.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can see here we have some very streamlined code, and not much of it.  Adding more form fields requires no changes to our javascript.  We can basically include this into a .js file and stamp it on any form we want.  A little tweaking and we could make it work for multiple databases as well.  You get the idea.&lt;br /&gt;&lt;br /&gt;Next, we'll talk about the dataservice.php in detail.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7067890369096756918?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/super-simple-ajax-forms-with-jquery-and_21.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-8172768462717530430</guid><pubDate>Tue, 20 Jan 2009 21:56:00 +0000</pubDate><atom:updated>2009-08-22T16:22:18.537-07:00</atom:updated><title>Super Simple AJAX Forms with jQuery and JSON : Introduction</title><description>I am a huge advocate of SOA architecture. I find it reduces code, encapsulates and makes for a very cohesive web environment. &amp;nbsp;Wow, what a sales pitch eh? &amp;nbsp;Seriously if you think that doing an&amp;nbsp;asynchronous&amp;nbsp;web application is more effort than it&amp;#39;s worth then you need to keep reading. &amp;nbsp;I developed this code example to illustrate just how elegant, simple and effective your web application can be. &amp;nbsp;Furthermore this code you are about to see is completely reusable. &amp;nbsp;You should be able to use it over and over again as a framework for all your web applications. &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;To illustrate just how simple this all is I have done it with just 2 files (3 if you count jQuery). &amp;nbsp;The client side webpage.html and the server side dataservice.php. &amp;nbsp;You can download the complete source code for these example, upload it to a PHP server and you&amp;#39;ll be on your way. &amp;nbsp;You&amp;#39;ll need only to create a simple database called users and some dummy data. &amp;nbsp;I did not include that in these examples since you should really be able to do all that yourself. &amp;nbsp;&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;The entire purpose of this&amp;nbsp;exercise was to create some clean and reusable code for managing a form where users need to edit data. &amp;nbsp;These type of forms have typically the following types of problems when you do it with traditional HTML and PHP.&lt;/div&gt; &lt;div&gt;&lt;ol&gt;&lt;li&gt;How do you know what data changed. &amp;nbsp;Usually developers replace all the data or do compares manually.&lt;/li&gt;&lt;li&gt;Many times code is placed inside the HTML/PHP to do the update. &amp;nbsp;Not very easy to read, poor design.&lt;/li&gt; &lt;li&gt;Code sometimes has includes or functions, hard to track things down. &amp;nbsp;It&amp;#39;s better but still very difficult to work with on larger systems.&lt;/li&gt;&lt;li&gt;HTML/PHP often has business logic mixed into the presentation layer. &amp;nbsp;Validation, etc.&lt;/li&gt; &lt;/ol&gt;&lt;div&gt;You wont find these types of problems in the code I&amp;#39;m providing you here. &amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;webpage.html&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The only logic in the HTML (and it&amp;#39;s just HTML and JavaScript) is the very simple aggregation and posting of data. &amp;nbsp;It also pulls data down and posts it into the form fields. &amp;nbsp;It also tracks which fields have been modified and only sends the data that needs to update. &amp;nbsp;That&amp;#39;s it.&lt;/div&gt; &lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;dataservice.php&lt;/span&gt;&lt;/div&gt;&lt;div&gt;This is the meat and potatoes. &amp;nbsp;This pulls data from the database and posts changes to it. &amp;nbsp;There is no &amp;quot;insert&amp;quot; code in here but you can easily build your own should you need it. &amp;nbsp;The framework in this example is designed to show you how easy AJAX/JSON can be. &amp;nbsp;The dataservice.php can easily be extended to validate and return responses such as &amp;quot;missing data&amp;quot;, &amp;quot;bad data&amp;quot;, etc. &amp;nbsp;Nice thing is your business logic is contained here. &amp;nbsp;It&amp;#39;s also not exposed out on the web where someone can use it against you and spam you or worse. &amp;nbsp;&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;jQuery&lt;/span&gt; is used to save ourselves a boatload of work. &amp;nbsp;It&amp;#39;s free and the AJAX libraries are easy to use. &amp;nbsp;I only use the simple methods here, I have used the more robust features in jQuery but for 99% of the users/web pages out there this works just fine.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;How it works&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The application works by pulling down a single record in the database. &amp;nbsp;After it pulls down the record it uses the JSON data (by parsing the key names) to find HTML ID&amp;#39;s using jQuery. &amp;nbsp;If there is a match with a FLD_ prefix on the field name then we populate it with our JSON data. &amp;nbsp;Then, anytime a field is changed on the form, we add a CSS class to it. &amp;nbsp;The CSS class serves two purposes. &amp;nbsp;First the user can see what data has changed and what will be posted. &amp;nbsp;Second, the code uses the class to determine which fields need to be sent to the server. &amp;nbsp;Finally, once the user clicks submit the changed fields are read, tied together in a GET url and sent off to the dataservice.php. &amp;nbsp;The service updates the record and returns success/failure.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;The next post we will&amp;nbsp;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;disassemble&amp;nbsp;&lt;/span&gt;webpage.html&lt;/span&gt; and cover how it works in detail.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;a href="/JSONSimpleExample.zip"&gt;Download Super Simple AJAX Source Code Example&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-8172768462717530430?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/super-simple-ajax-forms-with-jquery-and.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1190969888498260147</guid><pubDate>Sat, 10 Jan 2009 16:38:00 +0000</pubDate><atom:updated>2009-01-10T08:38:00.971-08:00</atom:updated><title>Print Buttons Anywhere</title><description>On item web developers often have to deal with is printing of web information for meetings.  You have information on the web page that looks great but is difficult to print without having a lot of extra information on the page.  &lt;br /&gt;&lt;br /&gt;Often, this problem is solved by creating a specific HTML page that then is handled by the server which in turn regenerates the information in a limited view and is placed in a popup window.  Which is not a bad solution but it does take some time to create that.  If you're working in a framework this might be a lot of effort for you.&lt;br /&gt;&lt;br /&gt;Here is a solution with jQuery that allows you to basically pick information off the page, stick it into a new document and then allow the user to print it.  You'll love the elgance of this small piece of code.&lt;br /&gt;&lt;br /&gt;First, lets start with the HTML.  Simply include a DIV around any elements you want to pick off the page.  Then, somewhere in there include a button, link, etc. which fires off the javascript to create the printable window.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="html"&gt;&lt;br /&gt;&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;div id="webContent"&gt;&lt;br /&gt; This is content you want to show on the page&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;input type="button" onclick="printMessage()" value="Printable View"&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Once you have the content on your site marked up (which you probably had done already) include this tasty nugget on your webpage.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="javascript"&gt;&lt;br /&gt;&lt;script&gt;&lt;br /&gt;    var printWP = "";&lt;br /&gt;    function printMessage(){&lt;br /&gt;  // Get Message From Content on Page&lt;br /&gt;        var msgHTML = "";&lt;br /&gt;        msgHTML += "&lt;p&gt;Printable View&lt;/p&gt;";&lt;br /&gt;        msgHTML += "&lt;p&gt;" + $("#webContent").html() + "&lt;/p&gt;";&lt;br /&gt;&lt;br /&gt;  // Build Web Page&lt;br /&gt;        var windowHTML = "&amp;lt;HTML&amp;gt;\n&amp;lt;HEAD&amp;gt;\n" +&lt;br /&gt;        "\n&amp;lt;/HEAD&amp;gt;\n&amp;lt;BODY&amp;gt;\n" +&lt;br /&gt;        msgHTML +&lt;br /&gt;        "\n&amp;lt;/BODY&amp;gt;\n&amp;lt;/HTML&amp;gt;";&lt;br /&gt;&lt;br /&gt;        // Open new browser window&lt;br /&gt;        printWP = window.open("", "webMessage", &lt;br /&gt;    "width=600,height=300,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes");&lt;br /&gt;        printWP.document.open();&lt;br /&gt;        // Insert Web Content&lt;br /&gt;        printWP.document.write(windowHTML);&lt;br /&gt;        printWP.document.close();&lt;br /&gt;&lt;br /&gt;        // Open print dialog &lt;br /&gt;        setTimeout("printWP.window.focus();printWP.window.print();", 2000);&lt;br /&gt;    }&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Let me explain what we do here.  We use jquery to pick off the webContent HTML.  $("#webContent").html() we stuff that into msgHTML.  We then use windowHTML to build up the actual HTML page that we will place into the new window.&lt;br /&gt;&lt;br /&gt;Note that the windoHTML code could have included the $("#webContent").html() call, but I listed them separately to better illustrate what exactly we are doing here.&lt;br /&gt;&lt;br /&gt;After we build the page, we open the web browser window with the window.open() call.&lt;br /&gt;&lt;br /&gt;Last, we call the print dialog.  Now you're probably wondering why I placed that in a settimeout.  Well I found on a few browsers (namely firefox 2) that if the page hasnt rendered that the print button can create a blank page.  This timeout allows the user to see the page, then a couple of seconds later the print dialog shows.  &lt;br /&gt;&lt;br /&gt;Alternatively (but not shown in this example) you could add jquery to the printable window then call the window.print() from within the actual page when the document is ready.  &lt;br /&gt;&lt;br /&gt;You get the idea though, this allows you to quickly be able to print any region of a website without all the extras and without having to create new pages on the server.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1190969888498260147?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/print-buttons-anywhere.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1701427315771421920</guid><pubDate>Thu, 08 Jan 2009 16:22:00 +0000</pubDate><atom:updated>2009-01-08T08:29:58.637-08:00</atom:updated><title>Icons after your links</title><description>Well this week I solved a problem with some highly creative jQuery code.   The problem was that IE6 doesnt support images in CSS in an anchor tag.  Well I came up with some jQuery code that allows you to easily add images after links with a very high level of control.  Far more control than CSS.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="javascript"&gt;&lt;br /&gt;   $(document).ready(function(){&lt;br /&gt;    $('a').each(function(){&lt;br /&gt;     if ($(this).attr('href').match(".pdf") != null) {&lt;br /&gt;      $(this).html($(this).html() + " &lt;img src=\"/images/icon.link.pdf.jpg\" border=\"0\" class=\"linkicon\" /&gt;");&lt;br /&gt;     }else if($(this).attr('href').match(".xls")!=null){&lt;br /&gt;      $(this).html($(this).html() + " &lt;img src=\"/images/icon.link.xls.jpg\" border=\"0\" class=\"linkicon\" /&gt;");&lt;br /&gt;     }else{&lt;br /&gt;      // do nothing&lt;br /&gt;     }&lt;br /&gt;    })&lt;br /&gt;   });  &lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;This example illustrates that once the document is ready, iterate each anchor tag and check to see if it's pointing at a PDF or an XLS file, if so, replace the HTML &lt;b&gt;inside&lt;/b&gt; the anchor tag with the existing content plus the image itself.&lt;br /&gt;&lt;br /&gt;This helps considerably when you want to enable this site wide.  You can see that I use the .match() function to see if the URL contains that piece of information.  &lt;br /&gt;&lt;br /&gt;This code works great if you place it in a footer and then enable it site wide.  This also has the advantage that you can have different CSS files for different pages and not worry about includes or copying references.  This works regardless of what page content is.&lt;br /&gt;&lt;br /&gt;The down side to using this is that the images are &lt;b&gt;not&lt;/b&gt; SEO friendly because this is done in javascript and not part of the page content itself.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1701427315771421920?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2009/01/icons-after-your-links.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1836457860736664250</guid><pubDate>Thu, 11 Dec 2008 18:16:00 +0000</pubDate><atom:updated>2008-12-11T10:30:37.778-08:00</atom:updated><title>Changes in web hosting</title><description>I have had the same web host for so many years I thought it might be good for me to research what the latest and greatest hosts are and what differences might be available.  When doing this I thought that others might like to understand how I research web hosts.&lt;br /&gt;&lt;br /&gt;When looking for &lt;a href="http://www.fusepoint.com/"&gt;managed hosting services&lt;/a&gt; you really should look for providers who have a good reputation, excellent value and knowledgeable staff. &lt;br /&gt;&lt;br /&gt;I generally break down my research into a few categories.  These categories allow you to rate each type of web host by each category and then decide which one best fits your needs.&lt;br /&gt;&lt;br /&gt;The categories I use are below.  You should rate from 1-5 how well the host performs in each area then decide if they are a good fit.&lt;br /&gt;&lt;br /&gt;1. Hosting presence - what sort of &lt;a href="http://www.fusepoint.com/english/html/data_centre_information.html"&gt;data center&lt;/a&gt; does the provider have.  What sort of bandwidth do they have available.  Is their pipline small or large?  Do they have a raised floor and fire prevention.  &lt;br /&gt;&lt;br /&gt;2. Features - What sort of features do they have.  Do they have cpanel, plesk or other hosting interfaces?  Do they allow you shell access, unlimited bandwidth and data pacakges, etc.&lt;br /&gt;&lt;br /&gt;3. Stability - This is big key.  There are a million fly by night places out there offering hosting.  You should make sure that the people running the place are reviewing their practices and methods of running their web hosting.  A good place to start is making sure they have &lt;a href="http://fusepoint.com/english/landing/landing_sas.html"&gt;SAS 70&lt;/a&gt; compliance.  What this means is basically they have someone independently audit them.  &lt;br /&gt;&lt;br /&gt;4. Knowledge in the industry - Feel free to ask them if they know the latest trend in security.  Ask them what the toughest problem they solved recently was.  It's important to have staff that can figure things out.  &lt;br /&gt;&lt;br /&gt;5. Value - Make sure you compare and weigh all the costs in your web hosting.&lt;br /&gt;&lt;br /&gt;Remember, when you're looking for hosting it's not about price but a combination of many things.  It only take a few days of downtime for someone to go surfing the web elsewhere!&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1836457860736664250?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/12/changes-in-web-hosting.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7260405523527604088</guid><pubDate>Thu, 11 Dec 2008 17:15:00 +0000</pubDate><atom:updated>2008-12-11T09:31:37.441-08:00</atom:updated><title>Web Table Sorting (Without the headache)</title><description>Most web developers at one time or another are going to run across a medium sized table they want to sort.  Sure, you can do this with PHP and send parameters clicking on each header but why?  You can use a little &lt;a href="http://www.jquery.com/"&gt;jQuery&lt;/a&gt; plug in called table sorter to get everything you need without any significant overhead.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://tablesorter.com/docs/#Demo"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://www.robsprogrammingjunk.com/uploaded_images/tablesort-738398.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Christians website has some really great tutorials and sample code.  If you're not using &lt;a href="http://www.jquery.com/"&gt;jQuery&lt;/a&gt; I suggest you give it a shot.  I've been using it for some time and it allows you to work considerably faster.  I've used this on a few projects now and ever user has been happy with the results.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7260405523527604088?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/12/web-table-sorting-without-headache.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-5461372311473800568</guid><pubDate>Thu, 13 Nov 2008 14:33:00 +0000</pubDate><atom:updated>2008-11-13T07:28:09.538-08:00</atom:updated><title>Google Chart API</title><description>It's no secret I'm a big fan of Google most developers are.  I've been using the Google chart API a lot lately and thought it should get some exposure in my Blog.  For those of you that follow my blog you really should be using this API.  It's so darn simple and has no overhead because google takes the hit on processing!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You simply use a URL to get your chart so you're ultimately limited by the URL length and their encoding.  While this wont be a full featured reporting system like Jasper or Pentaho putting quick graphs on a webpage or website is a piece of cake.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;http://chart.apis.google.com/chart?cht=p3&amp;chd=t:60,40&amp;chs=250x100&amp;chl=Hello|World&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://chart.apis.google.com/chart?cht=p3&amp;chd=t:60,40&amp;chs=250x100&amp;chl=Hello|World"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Is google's chart example and it's simple and elegant.  You can use any type of code to generate your URL.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Google has a &lt;a href="http://code.google.com/apis/chart/formats.html#simple"&gt;javascript code&lt;/a&gt; that can encode the URL with values to save space.  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I wrote some PHP code (below) that you can use to encode the same type of array with PHP.  This has the advantage of calling a function to encode it within your PHP page.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="php"&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;// Define Array of values (This could be data coming back from a datbase)&lt;br /&gt;$values = Array(10, 20, 30, 2, 44);&lt;br /&gt;echo simpleEncode($values, 1500);&lt;br /&gt;&lt;br /&gt;// Simple Encode Function converted to PHP code by rob@mechsoftware.com&lt;br /&gt;function simpleEncode($valueArray, $maxValue)&lt;br /&gt;{&lt;br /&gt;    $simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';&lt;br /&gt;    $chartData = Array('s:');&lt;br /&gt;&lt;br /&gt;    for ($i = 0; $i &lt; sizeof($valueArray); $i++){&lt;br /&gt;        $currentValue = $valueArray[$i];&lt;br /&gt;        if (!is_nan($currentValue) &amp;&amp; $currentValue &gt;= 0){&lt;br /&gt;            array_push($chartData, substr($simpleEncoding, round((strlen($simpleEncoding)-1)*$currentValue/$maxValue), 1));&lt;br /&gt;        }else{&lt;br /&gt;            array_push($chartData, '_');&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    return join('', $chartData);&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You should use this sort of API an in any website where you dont want (or need) to have a full blown reporting engine.  Stats and metrics can easily be charted with this.  Additionally when you read the full API you'll see you can also change colors, control chart types and do all sorts of neat stuff with it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These charts look great too.  Since the cost is low (Free) and the use is simple this is a great way to splash up any webpage with some simple calls to a URL.  Google allow you to do 250K of these requests a day which would be a lot for most websites.  A little tip too this saves on your overall badwidth on your website too.  250K requests for a 4.8K chart image is about 1.2 gig in bandwidth.  So google gives you that for free too. Unless you need some high customization there is no reason you shouldn't be using this everywhere.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Happy Charting!&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-5461372311473800568?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/11/google-chart-api.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-3494007863701662208</guid><pubDate>Thu, 04 Sep 2008 18:15:00 +0000</pubDate><atom:updated>2008-09-04T11:27:54.007-07:00</atom:updated><title>1PB Storage, $17,8800  Not bad eh?</title><description>So today while looking at the tiger direct deal for a $149 1TB SATA drive I wondered "just how long before someone has the 1PB (Petabyte) system.  Well quick search into google and I found one.  &lt;a href="http://searchstorage.techtarget.com/news/article/0,289142,sid5_gci1281803,00.html#"&gt;Check this article out&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;What is interesting is that a 1GB Seagate drive in 1995 cost $849, today, a 1TB drive for end consumers (13 years later) is only $149 at Tiger Direct.  So how long for the 1TB drive?&lt;br /&gt;&lt;br /&gt;Doing the math you can get 1200 SATA drives, chain 'em together and get 1PB of storage.  A bit pricey for me though.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-3494007863701662208?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/09/1pb-storage-178800-not-bad-eh.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-4107143709961052180</guid><pubDate>Wed, 03 Sep 2008 01:02:00 +0000</pubDate><atom:updated>2008-09-02T18:10:25.996-07:00</atom:updated><title>Google Chrome Anyone?</title><description>Wow, what a great first impression.  I downloaded Google Chrome today.  Installed the beta and now have it currently set as my default browser.  I tried the IE8 beta and instantly turned it back to IE7 Compatibility.  With Chrome I've only submitted 2 sites now that haven't looked right.  IE8 I didn't bother because everything looked funky.  &lt;br /&gt;&lt;br /&gt;Now being who I am I have to start digging into Chrome and under the hood.  From a web developer standpoint I think Chrome will fair well so far.  Out of the box websites look good.  I dont see huge problems in compatibility.  DOM seems to be sane and jQuery heavy pages work just fine.&lt;br /&gt;&lt;br /&gt;I like the clean look however IMHO google has very minimalist applications.  Why GoogleTalk is still lacking features like grouping is beyond me.  This post is about Chrome though.&lt;br /&gt;&lt;br /&gt;I have to say it is worth trying out.  I enjoy using it and unlike the IE8 beta I dont feel like i'm being forced anything down my throat.  Guess that's why Microsoft Developers leave for google all the time.  Why don't I work for Google?  &lt;br /&gt;&lt;br /&gt;It's no surprise I'm a google fan and I like the fresh thinking with the browser.  Seems fast, looks great and does the job.  I'll blog about it later after I've kicked the tires some more.  So far only good things to say...&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-4107143709961052180?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/09/google-chrome-anyone.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-4079092097361147015</guid><pubDate>Thu, 28 Aug 2008 16:01:00 +0000</pubDate><atom:updated>2008-08-28T09:03:34.343-07:00</atom:updated><title>Fun IT Stuff</title><description>This tasty little nugget I received from a friend.  There is some serious fun you can have with those pesky neighbors who hijack your wifi.  I personaly use WEP on mine but you might find it entertaining just a fun joke to play on your friends.&lt;br /&gt;&lt;br /&gt;Not your typical development stuff, but amusing at the very least.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-4079092097361147015?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/08/fun-it-stuff.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-1227057347491121437</guid><pubDate>Tue, 03 Jun 2008 02:30:00 +0000</pubDate><atom:updated>2008-06-02T19:41:46.777-07:00</atom:updated><title>Elegant Parsing Of Servlet Parameters</title><description>I love SOA. I use servlets to send back JSON data and I honestly believe it's the most elegant approach to asynchronous data over the web. Sure, AJAX and XML is great but JSON has some real flexibility when it comes to small size and larger payloads. I frequently use Java with a tomcat server to handle the data coming from the database. I get to use Hibernate and it makes life very easy.&lt;br /&gt;&lt;br /&gt;Today's post is about parsing servlet parameters. If you use SOA enough you'll find youre coding new servlet parameters all the time and your head begins to swim with all the work involved in reading and validating parameters. This is where this tasty nugget comes into play. I developed this to read the parameters and place them into a hashmap. The nice part about this is that you read the parameter set one time and the hashmap handles all sorts of things for you. &lt;br /&gt;&lt;br /&gt;First its easy to find stuff and check for missing parameters. You simply need to see if the key exists to know if you have a parameter. Next, there is no code overhead here in maintaining a list of the parameters you are checking and assigning them to variables, fields, etc. You simply reference the hash and convert when necessary. So you get cleaner code by having less of it. Try using this the next time you're coding a servlet and you'll find it makes your SOA go much faster.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="java"&gt;&lt;br /&gt;import java.util.Enumeration;&lt;br /&gt;import java.util.HashMap;&lt;br /&gt;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;&lt;br /&gt;&lt;br /&gt;public class ParameterMap {&lt;br /&gt;static public HashMap&lt;String, String&gt; convertRequestParametersToMap(HttpServletRequest request){&lt;br /&gt;Enumeration&lt;?&gt; initParameters=request.getParameterNames();&lt;br /&gt;HashMap&lt;String, String&gt; parameterMap = new HashMap&lt;String, String&gt;();&lt;br /&gt;while (initParameters.hasMoreElements()) {&lt;br /&gt;String param = (String) initParameters.nextElement();&lt;br /&gt;String value = request.getParameter(param);&lt;br /&gt;if (param != null &amp; value != null)&lt;br /&gt;parameterMap.put(param, value);&lt;br /&gt;}&lt;br /&gt;return parameterMap;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Please remember to make a post here if you use anything. I like to see how people are using my code.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-1227057347491121437?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/06/elegant-parsing-of-servlet-parameters.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-939809611216451972</guid><pubDate>Tue, 27 May 2008 17:21:00 +0000</pubDate><atom:updated>2008-05-27T10:24:03.877-07:00</atom:updated><title>Gave up on Vista</title><description>Well, despite my post on how to get a box resonably running well with vista I finally gave up and installed XP on the laptop.  Vista is such a memory pig that it just wasnt worth it.  I havent been impressed with the roumors on the next version either.  Microsoft better shape things up if they want to keep ahead in the desktop market.  Just my $.02&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-939809611216451972?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/05/gave-up-on-vista.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-3936359234985826982</guid><pubDate>Tue, 27 May 2008 17:14:00 +0000</pubDate><atom:updated>2008-05-27T10:21:00.849-07:00</atom:updated><title>Do it yourself SEO.  Free, Cheap SEO, no strings.</title><description>If you have wanted to do &lt;a href="http://www.frugalseo.com/"&gt;free and cheap SEO&lt;/a&gt; then you should check out frugalseo.com. I put together a very quick eBook on how to prevent being scammed and just get it done with a reasonable amount of effort. Sure, there are many resources for free information on the web that outlines the same thing but I put this together as a guide for people who don't know much about it. With so many "SEO Experts" out there scamming people I wanted to put something together others could benefit from.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-3936359234985826982?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/05/do-it-yourself-seo-free-cheap-seo-no.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7958979054720867010</guid><pubDate>Wed, 07 May 2008 21:02:00 +0000</pubDate><atom:updated>2008-05-07T14:04:48.162-07:00</atom:updated><title>New Websites</title><description>I've created for my wife and now maintaining two new websites.  Give a dog a toy which is a &lt;a href="http://www.giveadogatoy.com"&gt;Premium dog toy of the month club&lt;/a&gt; and we also created &lt;a href=""&gt;Your Pets And More - Unique Pet Supplies.&lt;/a&gt;  Both site focus on pet supplies, dog toys, small animal supplies and more.  Excellent stuff so I suggest that all my readers visit it.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7958979054720867010?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/05/new-websites.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-4492051182758040077</guid><pubDate>Mon, 18 Feb 2008 17:40:00 +0000</pubDate><atom:updated>2008-02-18T11:07:30.274-08:00</atom:updated><title>Vista Laptop and Development</title><description>I wanted to get a laptop which I could use for all my various tasks without spending a ton of money. I purchased an Acer 4720-4721 which is a 1.6 Dual Core Intel machine with a gig of ram.&lt;br /&gt;&lt;br /&gt;I have a Dual Core desktop for my regular development work but I wanted to get something for some light code changes as well as doing the day to day personal stuff like Quicken.&lt;br /&gt;Like everyone else I finally had to take the leap into Vista. I had tried the beta with my MSDN subscription, as well as Vista ultimate when I bought my new development workstation. I wasn't very impressed and it seemed to just be fat and bloated even on my 2.9 Dual Core workstation which went promptly back to XP. With the laptop though short of downloading all the drivers again I was going to have to get used to using Vista.&lt;br /&gt;&lt;br /&gt;I finally have my Vista installation running as well as my XP one but it did take some effort. I'm sure I'm still losing some performance in Vista overall but it seems to run as expected now. In fact I was able to bump up my 3.1 Experience Rating to a 3.2 by just doing a few things.&lt;br /&gt;First, Aero wears out really fast. I really don't need Flip 3d (who really does) and having transparent windows, light up buttons and everything else is just useless eye candy. For someone like myself who stares at code, UML diagrams, project requirements and emails all day it just wastes resources on the PC.&lt;br /&gt;&lt;br /&gt;Turning off Aero gave an immediate improvement. I also am not pleased with the black theme. I&lt;br /&gt;was able to download VistaGlazz and the Royale theme from the Internet. Google them, you'll end up with a nice bright look just like XP. In fact it seems so much happier than vista doom and gloom.&lt;br /&gt;&lt;br /&gt;Next I did a few searches on the Internet for some Vista tweaks. The largest ones were really just turning off some items in the start up like the welcome center. That was easy enough to do with Spybot Search and Destroy. I think that is a must have on any PC.&lt;br /&gt;&lt;br /&gt;While I was in there I turned off all the useless widgets that Acer installed on this thing. Start up tasks like launch managers, button key mappers, in all about 10 different things that really don't save me any time at all or are rarely used. Lean was the key to free up more memory for vista.&lt;br /&gt;I also went into the services and turned off everything I didn't need. I don't use a modem for anything so the modem sound driver seemed like another useless thing running and taking up space.&lt;br /&gt;&lt;br /&gt;Another trick I used on that Laptop was to install Trillian vs. MSN, Skype, GoogleTalk and Yahoo. Trillian allowed me to just load one messenger up vs. 4. Frankly all I do with those anyhow is talk to the wife, friends or colleagues in a IM window. So one footprint was better (and smaller).&lt;br /&gt;&lt;br /&gt;Now, I also threw in a 1GB SD I had laying around into the 5 in 1 reader that came on the laptop. The ReadyBoost does seem to add some enhancement in speed. Somewhat noticeable but if you 10 little things you start to notice the difference. I also doubted the ready boost but monitored the cache hits in the Performance Monitor and with less than 1ms seek time on a flash drive there is some benefit to using it.&lt;br /&gt;&lt;br /&gt;I also enabled the write caching on the laptop drive. I'll never run the battery to zero without knowing it so I'm willing to take the write cache hit should I be stupid enough to run out the battery.&lt;br /&gt;&lt;br /&gt;Last but not least I took off the wallpaper background. This frees considerable bitmap memory since one color is just, well one color.&lt;br /&gt;&lt;br /&gt;So let's recap what we did here to gain some big performance benefits.&lt;br /&gt;1. Remove the start up items you don't need.&lt;br /&gt;2. Remove the services you don't need&lt;br /&gt;3. Turn off Aero&lt;br /&gt;4. Reduce the number of Running apps.&lt;br /&gt;5. Enable Write caching&lt;br /&gt;6. Use ReadyBoost.&lt;br /&gt;&lt;br /&gt;Seems like a lot of work just for some performance gains but my vista now boots in what is perceived as about half the time. I also can switch windows faster and my hard drive is not chugging away every second.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-4492051182758040077?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/02/vista-laptop-and-development.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-7123986504284078787</guid><pubDate>Tue, 05 Feb 2008 16:52:00 +0000</pubDate><atom:updated>2008-02-05T08:57:07.307-08:00</atom:updated><title>JDIC Just Works</title><description>While I do a lot of J2EE work which is web enabled I love to tinker with desktop applications. I'm working on a personal project and wanted to embed a web browser into a Java application. I know of course how to do this in .NET however I prefer the cross platform capabilities in Java.&lt;br /&gt;&lt;br /&gt;This tasty nugget JDIC was just what I was looking for. While I was interested in only using the web browser to start there are more uses for this than that. With Linux closing in on Windows for the server market share applications that are OS independent are growing in popularity. JDIC I believe will help more developers write SE applications for any OS.&lt;br /&gt;&lt;br /&gt;JDIC can be found at &lt;a href="http://jdic.dev.java.net/"&gt;http://jdic.dev.java.net/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-7123986504284078787?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/02/jdic-just-works.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-26602852.post-5640708641126044273</guid><pubDate>Wed, 30 Jan 2008 01:01:00 +0000</pubDate><atom:updated>2008-01-29T17:18:41.550-08:00</atom:updated><title>Multiple Line JSF Data Tables</title><description>Ok, so you need to create a multi row data table right?  Now you want to do this with JSF and you see that you're up a creek without a paddle.  This doesnt fit the norm for most "grid" layouts on the web.  The standard JSF just doesnt allow for this with a datatable but you can use the panelgrid to get the results that you want.  Here is how.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="codeblock" class="xml"&gt;&lt;br /&gt;     &lt;h:dataTable value="#{reportListingReports.claimsToWork}"&lt;br /&gt;      var="ctwb" rowClasses="list-row-even, list-row-odd"&lt;br /&gt;      style="text-align: left; border-color: blue;" border="1"&lt;br /&gt;      cellpadding="0" cellspacing="0" columnClasses="list-column-all"&gt;&lt;br /&gt;      &lt;h:column id="FileName"&gt;&lt;br /&gt;       &lt;h:panelGrid columns="6" cellspacing="0"&lt;br /&gt;        columnClasses="report_cell_normal,report_cell_small,report_cell_normal,report_cell_normal,report_cell_small,report_cell_currency"&gt;&lt;br /&gt;        &lt;h:outputText value="#{ctwb.carrierName}&amp;nbsp;&amp;nbsp;&amp;nbsp;"&lt;br /&gt;         escape="false"&gt;&lt;/h:outputText&gt;&lt;br /&gt;        &lt;h:outputText value="#{ctwb.loadedDate}&amp;nbsp;&amp;nbsp;&amp;nbsp;"&lt;br /&gt;         escape="false"&gt;&lt;/h:outputText&gt;&lt;br /&gt;        &lt;h:outputLink&lt;br /&gt;         value="jsfReportDetail.jsp?reportEntryGUID=#{ctwb.id}"&gt;&lt;br /&gt;         &lt;h:outputText value="#{ctwb.patLastName}, #{ctwb.patFirstName}" /&gt;&lt;br /&gt;        &lt;/h:outputLink&gt;&lt;br /&gt;        &lt;h:outputText value="#{ctwb.patAccountNumber}"&gt;&lt;/h:outputText&gt;&lt;br /&gt;        &lt;h:outputText value="#{ctwb.beginDOS}"&gt;&lt;/h:outputText&gt;&lt;br /&gt;        &lt;h:outputText value="#{ctwb.totalCharge}"&gt;$&lt;f:convertNumber&lt;br /&gt;          currencyCode="US" maxIntegerDigits="10" minFractionDigits="2"&lt;br /&gt;          groupingUsed="true" maxFractionDigits="2" /&gt;&lt;br /&gt;        &lt;/h:outputText&gt;&lt;br /&gt;       &lt;/h:panelGrid&gt;&lt;br /&gt;       &lt;h:outputText value="#{ctwb.claimStatusCode}"&gt;&lt;/h:outputText&gt;: &lt;h:outputText&lt;br /&gt;        value="#{ctwb.claimMessage}"&gt;&lt;/h:outputText&gt;&lt;br /&gt;      &lt;/h:column&gt;&lt;br /&gt;     &lt;/h:dataTable&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Why don't we break this down to see what we do here.&lt;br /&gt;&lt;br /&gt;Line 1 is our standard data table layout using the backing bean reportListingReports.claimsToWork&lt;br /&gt;&lt;br /&gt;There is nothing new here, standard call to a backing bean for the JSF information.  We set the variable ctwb for use in the column.&lt;br /&gt;&lt;br /&gt;Line 5 is where we introduce the column.  As you can see here the matching tag for this is at line 25.  We use one column so we continue to iterate through our row data.&lt;br /&gt;&lt;br /&gt;Line 6 introduces our panel grid.  We use this to construct the real table here.  We continue to go down through the panelgrid and output the different elements using the ctwb variable.  &lt;br /&gt;&lt;br /&gt;Line 22 closes out the panelgrid.&lt;br /&gt;&lt;br /&gt;Line 23 gives us a summary row underneath.  I use this for outputting a status message on the previous row but you could introduce another panelgrid or whatever you like here.  &lt;br /&gt;&lt;br /&gt;So to summarize what we have here is 2 visible rows of data on the screen.  Presentation goes something like this.&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;ROW1COL1     ROW1OL2    ROW1COL3&lt;br /&gt;ROW2BUT BUT IS PART OF DATA ROW 1&lt;br /&gt;&lt;br /&gt;ROW2COL1     ROW2OL2    ROW2COL3&lt;br /&gt;ROW3BUT BUT IS PART OF DATA ROW 2&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;&lt;br /&gt;You should have the idea.  This gives nice formatting for anyone that needs to output a text description on the row but doesnt have the space on the screen (or in the data table column.&lt;br /&gt;&lt;br /&gt;Now, remember you'll need to use the column classes and style the table correctly or this may not look just right for you.  It is easy enough to acomplish with some css code.&lt;div class="blogger-post-footer"&gt;Copyright Robert W. Mech&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/26602852-5640708641126044273?l=www.robsprogrammingjunk.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.robsprogrammingjunk.com/2008/01/multiple-line-jsf-data-tables.html</link><author>noreply@blogger.com (Rob)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></item></channel></rss>