<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeff Douglas - Technology, Coding and Bears... OH MY! &#187; Google</title>
	<atom:link href="http://blog.jeffdouglas.com/category/cloud-computing/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jeffdouglas.com</link>
	<description>Get your head out of your #@! and into the clouds!</description>
	<lastBuildDate>Thu, 29 Jul 2010 19:04:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Using RSA-SHA1 with Salesforce Crypto Class</title>
		<link>http://blog.jeffdouglas.com/2010/07/06/using-rsa-sha1-with-salesforce-crypto-class/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-rsa-sha1-with-salesforce-crypto-class</link>
		<comments>http://blog.jeffdouglas.com/2010/07/06/using-rsa-sha1-with-salesforce-crypto-class/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 21:28:31 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=2754</guid>
		<description><![CDATA[This is a rather obscure post but it will definitely come in handy to someone trying to use the RSA-SHA1 algorithm with the Salesforce Crypto class. I&#8217;m spent the past two days trying to hook up OAuth using Apex and various Google Services. The standard HMAC-SHA1 algorithm is fairly straight forward with OAuth and Google [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both">This is a rather obscure post but it will definitely come in handy to someone trying to use the RSA-SHA1 algorithm with the Salesforce Crypto class. I&#8217;m spent the past two days trying to hook up OAuth using Apex and various Google Services. The standard HMAC-SHA1 algorithm is fairly straight forward with OAuth and Google but when you are required to register a domain and upload a certificate&#8230; well things get somewhat hairy. There&#8217;s very little documentation on the RSA-SHA2 algorithm and I could only find one relevant post on the topic.</p>
<p style="clear: both">According to the <a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_crypto.htm">Crypto docs</a>, the arguments for the <strong><u>sign</u></strong> method are an algorithm name (i.e., RSA-SHA1), an input Blob (the string to encrypt) and a privateKey Blob. The value of privateKey must be decoded using the EncodingUtilbase64Decode method, and should be in <a href="http://www.rsa.com/rsalabs/node.asp?id=2130" target="_blank">RSA&#8217;s PKCS #8 (1.2) Private-Key Information Syntax Standard form</a>. </p>
<p style="clear: both">The sample code from the docs doesn&#8217;t help determining how to obtain the privateKey:</p>
<p style="clear: both">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> algorithmName <span style="color: #339933;">=</span> <span style="color: #0000ff;">'RSA'</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> key <span style="color: #339933;">=</span> <span style="color: #0000ff;">'pkcs8 format private key'</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Blob</span> privateKey <span style="color: #339933;">=</span> EncodingUtil.<span style="color: #006633;">base64Decode</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Blob</span> input <span style="color: #339933;">=</span> <span style="color: #003399;">Blob</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'12345qwerty'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Crypto.<span style="color: #006633;">sign</span><span style="color: #009900;">&#40;</span>algorithmName, input, privateKey<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</p>
<p style="clear: both">So after a couple of days of trial and error, swearing and sticking needles in my eyes, I finally came up with the solution for Google. It may not apply to other services but the methodology is roughly the same for the privateKey.</p>
<p style="clear: both">The first step is to generate a self-signing public certificate and private key. You can find more info <a href="http://code.google.com/apis/gdata/docs/auth/authsub.html#Registered" target="_blank">here</a>. Open terminal and run the following:</p>
<p style="clear: both; font-family: Verdana;">openssl req -x509 -nodes -days 365 -newkey rsa:1024 -shal -subj &#8216;/C=US/ST=CA/L=San Mateo/CN=www.appirio.com&#8217; -keyout key-mycompanyrsa.pem -out cert-mycompanyrsa.pem</p>
<p style="clear: both">This will spit out a cert file (cert-mycompanyrsa.pem) and private key file (key-mycompanyrsa.pem). Then upload the cert to your domain for the <a href="https://www.google.com/accounts/ManageDomains" target="_blank">Google account</a>. This will generate a consumer key and a consumer secret for your application.</p>
<p style="clear: both">Now here was my mistake. I was opening the private key file (key-mycompanyrsa.pem) and using the contents of this file in my Apex code for the privateKey Blob value. Google was choking when creating the OAuth request token saying that the signature was incorrect: <strong><em>signature_invalid</em></strong>.</p>
<p style="clear: both">Here&#8217;s the fix. You need to use the private key file (key-mycompanyrsa.pem) with the openssl pkcs8 command to process the private keys into PKCS#8 format.</p>
<p style="clear: both">Open terminal again and run:</p>
<p style="clear: both; font-family: Verdana;">openssl pkcs8 -topk8 -nocrypt -in key-mycompanyrsa.pem -outform PEM</p>
<p style="clear: both">This will display a new private key in terminal and <strong><em>THIS</em></strong> is the value you use for the privateKey argument for the sign method. Just copy everything betweek the &#8220;begin&#8221; line and &#8220;end&#8221; line.</p>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/07/privatekey.png" class="image-link" rel="lightbox[2754]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/07/privatekey-thumb.png" height="275" align="left" width="380" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a></p>
<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2010/07/06/using-rsa-sha1-with-salesforce-crypto-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force.com Toolkit for Google Wave Demo at Google I/O</title>
		<link>http://blog.jeffdouglas.com/2010/06/10/force-com-toolkit-for-google-wave-demo-at-google-io/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=force-com-toolkit-for-google-wave-demo-at-google-io</link>
		<comments>http://blog.jeffdouglas.com/2010/06/10/force-com-toolkit-for-google-wave-demo-at-google-io/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 11:47:42 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Wave]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=2644</guid>
		<description><![CDATA[I attended this demo at Google I/O and am glad that the video is finally available. I&#8217;ve wanted to post it for awhile but Google put the video up about a week ago and then promptly took it down. Not sure why&#8230;? I think Quinton Wall and Kris Muller did an awesome job with this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jeffdouglas.com/2010/05/24/google-io-2010-recap/wavelogo-png/" rel="attachment wp-att-2598"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/wavelogo-150x150.png" alt="" title="wavelogo.png" width="150" height="150" class="alignleft size-thumbnail wp-image-2598" /></a>I attended this demo at Google I/O and am glad that the video is finally available. I&#8217;ve wanted to post it for awhile but Google put the video up about a week ago and then promptly took it down. Not sure why&#8230;? </p>
<p>I think <a href="http://twitter.com/cloudcoder">Quinton Wall</a> and Kris Muller did an awesome job with this demo. Quinton spent most of his time at Google I/O working the Developer Sandbox so it was good to see that Salesforce had such great representation at the event. Even <a href="http://twitter.com/dcarroll">Dave Carroll</a> graced the event with his presence. Every time I stopped by the booth they were busy giving demos. I know the Wave Team was very happy with the presentation and I overhead them talking very positively about it.</p>
<p>The use case for the demo was perfect. You have a team working an Opportunity and quickly want to start up a wave to begin collaborating on strategies to close it. With essentially one click you can spin up a wave with all team members and attach it to the Opportunity for historical reference. You can even invite resources from outside your domain to collaborate. The cool part of the demo is that Wave can then post updates to the Chatter feed using OAuth. I wanted to do something similar with Wave a couple of months ago about but was not able to since, at that time, a robot was not able to add participants. Glad to see that when the new <a href="http://googlewavedev.blogspot.com/2010/03/introducing-robots-api-v2-rise-of.html">Robots API v2</a> came out, Quinton was able to make this happen. Kudos to Quinton! Great job!</p>
<p>Scroll into minute 19 to see the start of the Salesforce portion of the demo. For more info on the toolkit, check out the <a href="http://wiki.developerforce.com/index.php/Forcedotcom_Toolkit_for_Google_Wave">An Introduction to the Force.com Toolkit for Google Wave</a>.</p>
<p><span class="youtube">
<object width="480" height="295">
<param name="movie" value="http://www.youtube.com/v/q8jjIMGB1Fw&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/q8jjIMGB1Fw&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="480" height="295"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=q8jjIMGB1Fw&fmt=18">www.youtube.com/watch?v=q8jjIMGB1Fw</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2010/06/10/force-com-toolkit-for-google-wave-demo-at-google-io/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google I/O 2010 Recap</title>
		<link>http://blog.jeffdouglas.com/2010/05/24/google-io-2010-recap/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=google-io-2010-recap</link>
		<comments>http://blog.jeffdouglas.com/2010/05/24/google-io-2010-recap/#comments</comments>
		<pubDate>Tue, 25 May 2010 02:40:19 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Wave]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=2603</guid>
		<description><![CDATA[I&#8217;m back from Google I/O 2010 in San Francisco and am finally able to take a breath. There were over 5,000 developers, 90+ technical sessions, over 180 companies peddling their tech in the Sandbox and a steady stream of product and technology announcements. It was two action-packed days of deep technical content featuring Android, Google [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/io2010logo-1.png" class="image-link" rel="lightbox[2603]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/io2010logo-1-thumb.png" height="93" align="left" width="175" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a>I&#8217;m back from <a href="http://code.google.com/events/io/2010/" target="_blank">Google I/O 2010</a> in San Francisco and am finally able to take a breath. There were over 5,000 developers, 90+ technical sessions, over 180 companies peddling their tech in the Sandbox and a steady stream of product and technology announcements. It was two action-packed days of deep technical content featuring Android, Google Chrome, Google APIs, GWT, App Engine, open web technologies and much, much more. I&#8217;m so glad to be working in the cloud with all of this new crap to play with! Here&#8217;s a short list of things that stuck out the most for me.</p>
<p style="clear: both">Vic Gundotra (Vice President, Engineering) stated that &#8220;I/O&#8221; represented &#8220;Innovation&#8221; and &#8220;Openness&#8221; and that was the theme throughout the two day event. Google relentlessly bashed Apple for their stance on a number of issues (no Flash, AT&#038;T only, policed App Store, etc) and cemented their &#8220;kumbayah&#8221; of inclusiveness and standards. Google drove home their support for HTML5, Flash and a new open-source, royalty-free video format called <a href="http://www.webmproject.org/about/" target="_blank">WebM</a>.</p>
<p style="clear: both">The Day 2 Keynote was awesome! One of the most riveting keynotes I&#8217;ve ever seen. You&#8217;ll definitely want to watch the video below.</p>
<p style="clear: both"><span class="youtube">
<object width="480" height="295">
<param name="movie" value="http://www.youtube.com/v/IY3U2GXhz44&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/IY3U2GXhz44&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="480" height="295"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=IY3U2GXhz44&fmt=18">www.youtube.com/watch?v=IY3U2GXhz44</a></p></p>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/froyo.png" class="image-link" rel="lightbox[2603]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/froyo-thumb.png" height="126" align="left" width="150" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><strong>Android, Android and more Android</strong><br />This might have well been called the &#8220;Android Developer&#8217;s Conference&#8221; as most of the emphasis was on their mobile platform. I have to admit that they didn&#8217;t disappoint. All of Android sessions and labs were packed and some even turned away people. I attended a couple of hacker sessions including development best practices, game development and building REST clients. </p>
<p style="clear: both">Last year Google gave every attendee a Nexus One at the event. This year they were smart and shipped everyone a Nexus One or Droid a month before the event to help them get up and running on the Android platform. Then, to everyone&#8217;s surprise, they gave everyone on day 2 <strong><em><u>another</u></em></strong> Android device; the <a href="http://now.sprint.com/evo/" target="_blank">Sprint HTC EVO</a> that ships next month. I&#8217;m seriously in love with this phone and am considering giving up my iPhone. </p>
<p style="clear: both">The major announcement was the release of Android 2.2 Froyo (Frozen Yogurt). Some of the highlight include:</p>
<p style="clear: both">
<ul style="clear: both">
<li>2-5x speed increase with devices running the Dalvik just-in-time (JIT) compiler</li>
<li>2-3x browser speed improvement with the Chrome V8 engine </li>
<li>Support for Microsoft Exchange</li>
<li>Flash support</li>
<li>Tethering and Portable Hotspot</li>
<li>App Storage on SD -- run app directly from the SD card</li>
<li>Update All and Auto-update for applications</li>
</ul>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/appengine4.jpg" class="image-link" rel="lightbox[2603]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/appengine4-thumb.jpg" height="111" align="left" width="145" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><strong>App Engine for Business</strong><br />After two years, Google finally announced a service target specifically at small businesses. The service adds management and support features tailored specifically for the enterprise allowing them to take advantage of the core benefits of Google App Engine: easy development using familiar languages (Java and Python); simple administration, with no need to worry about hardware, patches or backups; and effortless scalability. However, some of the details, especially pricing, were fuzzy. My favorite was announced support for SQL databases (presumably MySQL).</p>
<p style="clear: both">
<ul style="clear: both">
<li>Centralized administration: A new, company-focused administration console lets companies manage all the applications in their domain.</li>
<li>Reliability and support: 99.9% uptime service level agreement, with premium developer support available.</li>
<li>Secure by default: Only users from the Google Apps domain can access applications and corporate security policies are enforced on every app.</li>
<li>Pricing that makes sense: Each application costs just $8 per user, per month up to a maximum of $1000 a month. This is the part I didn&#8217;t quite understand as it must be for non-domain users.</li>
<li>Enterprise features: Coming later this year, hosted SQL databases, SSL on the company’s domain for secure communications, and access to advanced Google services.</li>
</ul>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/wavelogo.png" class="image-link" rel="lightbox[2603]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/wavelogo-thumb.png" height="150" align="left" width="150" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><strong>Google Wave</strong><br />Over the last number of months the Wave team has made a number of enhancements to the service. They&#8217;ve added an <a href="http://googlewave.blogspot.com/2010/05/discover-your-favorite-extension-today.html" target="_blank">extensions gallery</a>, <a href="http://googlewavedev.blogspot.com/2010/03/introducing-robots-api-v2-rise-of.html" target="_blank">Robots API v2</a>, Active Robot API and an <a href="http://googlewavedev.blogspot.com/2010/04/embed-api-improvements-viewing-public.html" target="_blank">anonymous read-only access for embedded waves</a>. They made the statement in a number of sessions that if you tried Wave in the past to please come back and take a look at Wave now given the number of enhancements. Google also went so far as to make Wave available for Google Apps (Standard, Premier and Education Editions). Some features announced at I/O include:</p>
<p style="clear: both">
<ul style="clear: both">
<li>Run robots on any server &#8212; not just App Engine. They also announced that you can program robots in <a href="http://code.google.com/p/go/" target="_blank">Google Go</a>.</li>
<li>Use a robot to manipulate and retrieve attachments within a wave</li>
<li>Use the &#8220;Wave This&#8221; service to let your website&#8217;s visitors easily create waves out of the content on your site. </li>
<li>Fetch waves on behalf of users with Wave data APIs</li>
</ul>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/gwt-logo.png" class="image-link" rel="lightbox[2603]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/gwt-logo-thumb.png" height="100" align="left" width="100" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><strong>Google Web Toolkit</strong><br />GWT sessions were quite numerous and popular and the Day 1 keynote revealed some exciting new features. VMware and Google announced a collaboration centered around the Spring programming model, <a href="tp://www.springsource.com/products/sts" target="_blank">SpringSource Tool Suite</a> and <a href="http://www.springsource.org/roo" target="_blank">Spring Roo</a>. The highlights of the announcement include:</p>
<p style="clear: both">
<ul style="clear: both">
<li>Tight integration with SpringSource Tool Suite and Spring Roo to provide a polished, productive developer experience</li>
<li>Innovative, close integration between Spring and Google Web Toolkit offering the ability to build rich applications with amazing speed</li>
<li>The ability to easily target Spring applications to Google App Engine</li>
<li>A compelling integration between Spring Insight and Google Speed Tracer to provide insight into the performance of Spring applications from browser to database</li>
</ul>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/tv_logo.gif" class="image-link" rel="lightbox[2603]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/05/tv_logo-thumb.gif" height="40" align="left" width="133" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><strong>Google TV</strong><br />This was the main announcement of the second half of the Day 2 keynote. A lot of people were surprised as there were talks of a Google tablet in the air. The keynote demo was very interesting as they ran into a number of glitches involving Bluetooth connectivity between the keyboard and set top box (no one thought of bringing a standard keyboard with a cable?). The idea is not new but they are bringing together some industry powerhouses (Sony, Intel, Adobe, Best Buy, Logitech and Dish Network) to bring the concept to market by this Christmas. TechCrunch has a <a href="http://techcrunch.com/2010/05/20/google-tv/" target="_blank">really good review</a> of Google TV.</p>
<p style="clear: both">Some other interesting announcements were:</p>
<p style="clear: both">
<ul style="clear: both">
<li><a href="http://code.google.com/apis/storage/" target="_blank">Google Storage for Developers</a> -- store your data in Google&#8217;s cloud</li>
<li><a href="https://chrome.google.com/webstore" target="_blank">Chrome Web Store</a> -- an app store for websites</li>
<li><a href="http://code.google.com/apis/predict/" target="_blank">Google Prediction API</a> -- machine learning algorithms to analyze your historic data and predict likely future outcomes</li>
<li><a href="http://googlecode.blogspot.com/2010/05/introducing-webfont-loader-in.html" target="_blank">WebFont API</a> -- support for web fonts</li>
<li><a href="http://googlecode.blogspot.com/2010/05/introducing-google-buzz-api.html" target="_blank">Google Buzz API</a> -- access to the Buzz platform</li>
<li><a href="http://googlecode.blogspot.com/2010/05/with-new-google-latitude-api-build.html" target="_blank">Latitude API</a> -- a simple way to share your location with whomever you like</li>
</ul>
<p></p>
<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2010/05/24/google-io-2010-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Appirio Announces PS Connect at Google Campfire One</title>
		<link>http://blog.jeffdouglas.com/2010/03/10/appirio-announces-ps-connect-at-google-campfire-one/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=appirio-announces-ps-connect-at-google-campfire-one</link>
		<comments>http://blog.jeffdouglas.com/2010/03/10/appirio-announces-ps-connect-at-google-campfire-one/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 14:28:34 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Appirio]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[The Internet Business]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=2307</guid>
		<description><![CDATA[Last night at Google Campfire One we demonstrated PS Connect, a new extension to our PS Enterprise product that allows service professionals to run their business directly from their Gmail inbox. We were the closing presentation for the night and you can view the video of the demo below. It&#8217;s roughly a 5 minute video [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/03/PSConnect2.gif" class="image-link" rel="lightbox"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/03/PSConnect2-thumb.gif" height="136" align="left" width="200" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a>Last night at <a href="http://code.google.com/campfire/">Google Campfire One</a> we demonstrated <a href="http://www.appirio.com/products/PSEconnect.php" target="_blank">PS Connect</a>, a new extension to our PS Enterprise product that allows service professionals to run their business <strong><em>directly from their Gmail inbox</em></strong>. We were the closing presentation for the night and you can view the video of the demo below. It&#8217;s roughly a 5 minute video and is really great!</strong></p>
<p style="clear: both">So what is PS Connect? PS Connect allows you to use Google Apps as a front end to cloud-based business applications. With our Gmail contextual gadgets you can take actions from inside your Gmail inbox instead of logging into multiple systems.</p>
<p>You can read the <a href="http://blog.appirio.com/2010/03/google-campfire-one-enterprise-apps-get.html" target="_blank">full announcement</a> on our website or get <a href="http://www.appirio.com/products/PSEconnect.php" target="_blank">more info on PS Connect</a>. If you&#8217;d like a deeper dive, you can even sign up for a <a href="http://thecloud.appirio.com/PSE-Demo.html" target="_blank">30 minute demo</a>.</p>
<p style="clear: both"><span class="youtube">
<object width="480" height="295">
<param name="movie" value="http://www.youtube.com/v/sO0gSFBlhrI&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/sO0gSFBlhrI&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="480" height="295"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=sO0gSFBlhrI&fmt=18">www.youtube.com/watch?v=sO0gSFBlhrI</a></p></p>
<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2010/03/10/appirio-announces-ps-connect-at-google-campfire-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GWT UiBinder Hello World Tutorial</title>
		<link>http://blog.jeffdouglas.com/2010/01/19/gwt-uibinder-hello-world-tutorial/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=gwt-uibinder-hello-world-tutorial</link>
		<comments>http://blog.jeffdouglas.com/2010/01/19/gwt-uibinder-hello-world-tutorial/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 23:26:03 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google App Engine]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=2041</guid>
		<description><![CDATA[I&#8217;ve been working on a new project the past couple of weeks that (fortunately) requires Google Web Toolkit (GWT) and I wanted to use the new UiBinder that was released with GWT 2.0 in early December for a number of reasons (clean separation of UI and code, easier collaboration with designers, easier testing, etc ). [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both">I&#8217;ve been working on a new project the past couple of weeks that (fortunately) requires <a href="http://code.google.com/webtoolkit" title="GWT" target="_blank">Google Web Toolkit</a> (GWT) and I wanted to use the new <a href="http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html" title="UiBinder" target="_blank">UiBinder</a> that was released with GWT 2.0 in early December for a number of reasons (clean separation of UI and code, easier collaboration with designers, easier testing, etc ). However, I was having a hard time getting my head wrapped around it given that the GWT site has very little documentation and only a few examples. I&#8217;ve combed through the message boards, the docs and the sample Mail application that comes with the SDK and after finally groking the new functionality, I put together a little Hello World app, the kind that would have helped me out originally. </p>
<p style="clear: both">So I&#8217;m making some assumptions that you already have the GWT SDK and Eclipse Plugin installed and are familiar with both of them. If you are not, take a look at the <a href="http://code.google.com/webtoolkit" target="_blank">GWT site</a> for more info.</p>
<p style="clear: both">To get started, create a new Web Application Project called &#8220;HelloUiBinder&#8221; in the package of your choice but do not check &#8220;Use Google App Engine&#8221;.</p>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-new-project1.png" class="image-link" rel="lightbox[2041]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-new-project1-thumb.png" height="575" align="left" width="509" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><br style="clear: both" />Now create a new UiBinder template and owner class (File -> New -> UiBinder). Choose the client package for the project and then name it <em>MyBinderWidget</em>. Leave all of the other defaults. When you click Finish the plugin will create a new UiBinder template and owner class.</p>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-new-binder.png" class="image-link" rel="lightbox[2041]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-new-binder-thumb.png" height="500" align="left" width="530" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><br style="clear: both" />Open the <em>MyBinderWidget.ui.xml</em> template and add the following code. With GWT you can define your styles either in your template where you need them or externally. I&#8217;ve added a small style inline that adds some pizzaz to the label. Notice the field name <em>myPanelContent</em> in the template. You can programmatically read and write to this field from the template&#8217;s owner class. So when the owner class runs, it construct a new VerticalPanel, does something with it (probably add some type of content) and then fill this field with it.</p>
<p style="clear: both">Attributes for the elements (the text attribute in the Label element for example) correspond to a setter method for the widget. Unfortunately there is no code completion to get a list of these attributes in Eclipse when you hit the space bar so you either have to know the setters or refer to the JavaDocs each time. A painful process.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span>DOCTYPE ui<span style="color: #339933;">:</span>UiBinder SYSTEM <span style="color: #0000ff;">&quot;http://dl.google.com/gwt/DTD/xhtml.ent&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>ui<span style="color: #339933;">:</span>UiBinder xmlns<span style="color: #339933;">:</span>ui<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;urn:ui:com.google.gwt.uibinder&quot;</span>
     xmlns<span style="color: #339933;">:</span>g<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;urn:import:com.google.gwt.user.client.ui&quot;</span><span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>ui<span style="color: #339933;">:</span>style<span style="color: #339933;">&gt;</span>
          .<span style="color: #006633;">bolder</span> <span style="color: #009900;">&#123;</span> font<span style="color: #339933;">-</span>weight<span style="color: #339933;">:</span>bold<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
     <span style="color: #339933;">&lt;/</span>ui<span style="color: #339933;">:</span>style<span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>HTMLPanel<span style="color: #339933;">&gt;</span>
          <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span><span style="color: #003399;">Label</span> styleName<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{style.bolder}&quot;</span> text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;This is my label in bold!&quot;</span><span style="color: #339933;">/&gt;</span>
          <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>VerticalPanel ui<span style="color: #339933;">:</span>field<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;myPanelContent&quot;</span> spacing<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;5&quot;</span><span style="color: #339933;">/&gt;</span>
     <span style="color: #339933;">&lt;/</span>g<span style="color: #339933;">:</span>HTMLPanel<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ui<span style="color: #339933;">:</span>UiBinder<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p style="clear: both">For the owner class, <em>MyBinderWidget.java</em>, add the following code. In this class, a field with the same name, <em>myPanelContent</em>, is marked with the @UiField annotation. When uiBinder.createAndBindUi(this) is run, the content is created for the VerticalPanel and the template field is filled with the new instance.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.jeffdouglas.client</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.core.client.GWT</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.uibinder.client.UiBinder</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.uibinder.client.UiField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.Composite</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.HTML</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.VerticalPanel</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.Widget</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyBinderWidget <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Composite</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> MyBinderWidgetUiBinder uiBinder <span style="color: #339933;">=</span> GWT
               .<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>MyBinderWidgetUiBinder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">interface</span> MyBinderWidgetUiBinder <span style="color: #000000; font-weight: bold;">extends</span> UiBinder<span style="color: #339933;">&lt;</span>widget, MyBinderWidget<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
     @UiField VerticalPanel myPanelContent<span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">public</span> MyBinderWidget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          initWidget<span style="color: #009900;">&#40;</span>uiBinder.<span style="color: #006633;">createAndBindUi</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #003399;">HTML</span> html1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HTML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          html1.<span style="color: #006633;">setHTML</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;a href='http://www.google.com'&gt;Click me!&lt;/a&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          myPanelContent.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>html1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #003399;">HTML</span> html2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HTML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          html2.<span style="color: #006633;">setHTML</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;This is my sample &lt;b&gt;content&lt;/b&gt;!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          myPanelContent.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>html2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="clear: both">Now change the entry point class to look like the following.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.jeffdouglas.client</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.core.client.EntryPoint</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.RootPanel</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloUiBinder <span style="color: #000000; font-weight: bold;">implements</span> EntryPoint <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onModuleLoad<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          MyBinderWidget w <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyBinderWidget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          RootPanel.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>w<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="clear: both">Now open <em>HelloUiBinder.html</em> and remove all of the HTML content between the &lt;/noscript&gt; and and &lt;/body&gt; save it. Once you run the application, copy the development URL and run paste it into your favorite supported browser, you should see the following.</p>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-results.png" class="image-link" rel="lightbox[2041]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-results-thumb.png" height="117" align="left" width="265" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a><br style="clear: both" />Now suppose you wanted to nest a widget inside your MyBinderWidget that did something when a button was clicked. We&#8217;ll create a small series of checkboxes that allows the user to select their favorite colors and display them when the button is clicked. Create a new UiBinder called <em>FavoriteColorWidget</em> in the client package. Add the following code to the <em>FavoriteColorWidget.ui.xml</em> template.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>ui<span style="color: #339933;">:</span>UiBinder xmlns<span style="color: #339933;">:</span>ui<span style="color: #339933;">=</span><span style="color: #0000ff;">'urn:ui:com.google.gwt.uibinder'</span>
    xmlns<span style="color: #339933;">:</span>g<span style="color: #339933;">=</span><span style="color: #0000ff;">'urn:import:com.google.gwt.user.client.ui'</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>VerticalPanel<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span><span style="color: #003399;">Label</span> ui<span style="color: #339933;">:</span>field<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;greeting&quot;</span><span style="color: #339933;">/&gt;</span>
      <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>Label<span style="color: #339933;">&gt;</span>Choose your favorite color<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">:&lt;/</span>g<span style="color: #339933;">:</span>Label<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>CheckBox ui<span style="color: #339933;">:</span>field<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;red&quot;</span> formValue<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;red&quot;</span><span style="color: #339933;">&gt;</span>Red<span style="color: #339933;">&lt;/</span>g<span style="color: #339933;">:</span>CheckBox<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>CheckBox ui<span style="color: #339933;">:</span>field<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;white&quot;</span> formValue<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;white&quot;</span><span style="color: #339933;">&gt;</span>White<span style="color: #339933;">&lt;/</span>g<span style="color: #339933;">:</span>CheckBox<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>CheckBox ui<span style="color: #339933;">:</span>field<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;blue&quot;</span> formValue<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;blue&quot;</span><span style="color: #339933;">&gt;</span>Blue<span style="color: #339933;">&lt;/</span>g<span style="color: #339933;">:</span>CheckBox<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span><span style="color: #003399;">Button</span> ui<span style="color: #339933;">:</span>field<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;button&quot;</span><span style="color: #339933;">&gt;</span>Submit<span style="color: #339933;">&lt;/</span>g<span style="color: #339933;">:</span>Button<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>g<span style="color: #339933;">:</span>VerticalPanel<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ui<span style="color: #339933;">:</span>UiBinder<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p style="clear: both">Now add the click handler in the <em>FavoriteColorWidget.java</em> owner class.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.jeffdouglas.client</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.core.client.GWT</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.event.dom.client.ClickEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.event.dom.client.ClickHandler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.uibinder.client.UiBinder</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.uibinder.client.UiField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.Window</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.Button</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.Label</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.CheckBox</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.Composite</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.Widget</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FavoriteColorWidget <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Composite</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> FavoriteColorWidgetUiBinder uiBinder <span style="color: #339933;">=</span> GWT
               .<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>FavoriteColorWidgetUiBinder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">interface</span> FavoriteColorWidgetUiBinder <span style="color: #000000; font-weight: bold;">extends</span>
               UiBinder<span style="color: #339933;">&lt;</span>widget, FavoriteColorWidget<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
     @UiField <span style="color: #003399;">Label</span> greeting<span style="color: #339933;">;</span>
     @UiField CheckBox red<span style="color: #339933;">;</span>
     @UiField CheckBox white<span style="color: #339933;">;</span>
     @UiField CheckBox blue<span style="color: #339933;">;</span>
     @UiField <span style="color: #003399;">Button</span> button<span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">public</span> FavoriteColorWidget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          initWidget<span style="color: #009900;">&#40;</span>uiBinder.<span style="color: #006633;">createAndBindUi</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #666666; font-style: italic;">// add a greeting</span>
          greeting.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello Jeff!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #000000; font-weight: bold;">final</span> ArrayList<span style="color: #339933;">&lt;</span>checkBox<span style="color: #339933;">&gt;</span> checkboxes <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>checkBox<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          checkboxes.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>red<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          checkboxes.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>white<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          checkboxes.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>blue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// add a button handler to show the color when clicked</span>
          button.<span style="color: #006633;">addClickHandler</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ClickHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span>ClickEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003399;">String</span> t <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
                    <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>CheckBox box <span style="color: #339933;">:</span> checkboxes<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                         <span style="color: #666666; font-style: italic;">// if the box was checked</span>
                         <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>box.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                              t <span style="color: #339933;">+=</span> box.<span style="color: #006633;">getFormValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">;</span>
                         <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #003399;">Window</span>.<span style="color: #006633;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Your favorite color/colors are: &quot;</span><span style="color: #339933;">+</span> t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="clear: both">The last thing we&#8217;ll need to do is add our new widget to the MyBinderWidget template. Open <em>MyBinderWidget.ui.xml</em> and add the custom namespace reference and the FavoriteColorWidget.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span>DOCTYPE ui<span style="color: #339933;">:</span>UiBinder SYSTEM <span style="color: #0000ff;">&quot;http://dl.google.com/gwt/DTD/xhtml.ent&quot;</span><span style="color: #339933;">&gt;;</span>
<span style="color: #339933;">&lt;</span>ui<span style="color: #339933;">:</span>UiBinder xmlns<span style="color: #339933;">:</span>ui<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;urn:ui:com.google.gwt.uibinder&quot;</span>
     xmlns<span style="color: #339933;">:</span>g<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;urn:import:com.google.gwt.user.client.ui&quot;</span>
     xmlns<span style="color: #339933;">:</span>c<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;urn:import:com.jeffdouglas.client&quot;</span><span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>ui<span style="color: #339933;">:</span>style<span style="color: #339933;">&gt;</span>
          .<span style="color: #006633;">bolder</span> <span style="color: #009900;">&#123;</span> font<span style="color: #339933;">-</span>weight<span style="color: #339933;">:</span>bold<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
     <span style="color: #339933;">&lt;/</span>ui<span style="color: #339933;">:</span>style<span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>HTMLPanel<span style="color: #339933;">&gt;</span>
          <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span><span style="color: #003399;">Label</span> styleName<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{style.bolder}&quot;</span> text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;This is my label in bold!&quot;</span><span style="color: #339933;">/&gt;</span>
          <span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>VerticalPanel ui<span style="color: #339933;">:</span>field<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;myPanelContent&quot;</span> spacing<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;5&quot;</span><span style="color: #339933;">/&gt;</span>
          <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>FavoriteColorWidget<span style="color: #339933;">/&gt;</span>
     <span style="color: #339933;">&lt;/</span>g<span style="color: #339933;">:</span>HTMLPanel<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ui<span style="color: #339933;">:</span>UiBinder<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p style="clear: both">Now when you run the application it should look like the following.</p>
<p style="clear: both"><a href="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-results2.png" class="image-link" rel="lightbox[2041]"><img class="linked-to-original" src="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/uibinder-results2-thumb.png" height="191" align="left" width="550" style=" display: inline; float: left; margin: 0 10px 10px 0;" /></a></p>
<p>  <br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2010/01/19/gwt-uibinder-hello-world-tutorial/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Calling a REST Web Service (JSON) with Apex</title>
		<link>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=calling-a-json-rest-web-service-with-apex</link>
		<comments>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 12:22:38 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Appirio]]></category>
		<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Visualforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1953</guid>
		<description><![CDATA[Cross-posted at the Appirio Tech Blog. Using JSON RESTful Web Services with Salesforce.com opens up your org to a number third-party integration opportunities (Google, Yahoo!, Flickr, bespoke, etc.). JSON support isn&#8217;t baked into the Force.com platform but Ron Hess at Salesforce.com has created a JSON parser which will do the heavy lifting for you. Last [...]]]></description>
			<content:encoded><![CDATA[<p>Cross-posted at the <a href="http://techblog.appirio.com/2010/01/calling-rest-web-service-json-with-apex.html" target="_blank">Appirio Tech Blog</a>.</p>
<p>Using JSON RESTful Web Services with Salesforce.com opens up your org to a number third-party integration opportunities (Google, Yahoo!, Flickr, bespoke, etc.). <a href="http://json.org" target="_blank">JSON</a> support isn&#8217;t baked into the Force.com platform but <a href="http://twitter.com/vnehess">Ron Hess</a> at Salesforce.com has created a <a href="http://code.google.com/p/apex-library/">JSON parser</a> which will do the heavy lifting for you.</p>
<p>Last month I wrote a <a href="http://blog.jeffdouglas.com/2009/12/04/calling-a-rest-web-service-with-apex/" target="_blank">blog post</a> and example of how to call a REST Web Service with Apex that returns and consumes XML. It was my intention to do the same demo using JSON, however, I ran into a small sang. I couldn’t get the Apex JSONObject parser to work. I tried on and off for a couple of days but couldn&#8217;t beat it into submission. I checked around the twitter-verse and no one reported much success using the JSON parser with complex objects. I <a href="http://blog.jeffdouglas.com/2009/12/28/problems-parsing-json-responses-with-apex/" target="_blank">finally cried &#8220;uncle&#8221;</a> and called Ron and asked for help. Ron was extremely responsive and over the course of a couple of days we worked worked through some of the <a href="http://code.google.com/p/apex-library/source/detail?r=13" target="_blank">parsing issues</a> and finally updated the Google project with the changes.</p>
<p><a href="https://jeffdouglas-developer-edition.na5.force.com/examples/RestDemoJson" target="_blank"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2010/01/REST-Json.png" alt="" title="REST-Json" width="500" class="alignnone size-full wp-image-1966" /></a></p>
<p>I put together a small demo where you enter your address and the Apex code fetches the address and coordinates from the Google Maps . The service returns the data as a JSON object. <strong>You can <a href="https://jeffdouglas-developer-edition.na5.force.com/examples/RestDemoJson" target="_blank">run this example</a> on my Developer Site.</strong></p>
<p>To get started, you&#8217;ll need to <a href=" http://code.google.com/p/apex-library/source/browse/trunk/JSONObject/src/unpackaged/classes/JSONObject.cls" target="_blank">download the JSONObject class</a> and install it into a Developer org or Sandbox. Unfortunately there is no documentation for the parser so you have to extrapolate from the <a href="http://www.json.org/" target="_blank">json.org</a> website.</p>
<p>You&#8217;ll also need to <a href="http://code.google.com/apis/maps/signup.html" target="_blank">sign up for a Google Maps API key</a> in order to use their geocoding service. I would also recommend that you take a <a href="http://code.google.com/apis/maps/documentation/geocoding/#JSON" target="_blank">look at the docs</a> for Google Maps geocoding service.</p>
<p>Here is the Controller for the demo. The interesting stuff is in the getAddress() and toGeoResult() methods. In getAddress(), the user-entered address is used to construct the URL for the GET call to the geocoding service. Make sure you properly encode the address or you may receive undesirable results returned from Google. One thing to point out is line #58. Google is returning a line feed in their JSON response which causes the JSON parser to choke. I simply replace all like feeds with spaces and that did the trick. Ron was going to look into making this change to the JSONObject class in the near future.</p>
<p>I was also having some problems with the geocoding service so I hard-coded the returned JSON object for testing. I checked around and it seems to be a <a href="http://www.google.com/search?hl=en&#038;q=google+maps+620+error&#038;aq=f&#038;oq=&#038;aqi=g1" target="_blank">common problem</a> that the Google Maps API randomly returns 620 errors when overloaded. <strong>You might want to take a look at the <a href="http://maps.google.com/maps/geo?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA&#038;output=json&#038;sensor=false" target="_blank">JSON response returned</a> for the hard-coded address.</strong> I will give you a little insight for the parsing process.</p>
<p>The toGeoResult() method parses the returned JSON response and populates the GeoResult object with the appropriate data. I chose this Google Maps example because it shows how to parse simple values, nested JSON objects and arrays. The coordinates for the address can either be returned as integers or doubles so I have to check each one.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RestDemoJsonController <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> geoAddress <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span>set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> address <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span>set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> city <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span>set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> state <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span>set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Boolean</span> useGoogle <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span>set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// google api key</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> apiKey <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span>set <span style="color: #009900;">&#123;</span> apiKey <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ABQIAAAAlI0DHB0p0WGX35GrKEAzQhTwZth5GdZI-P7ekoe_gyhfzl1yZhRAYdM-hb7aEWu30fGchcvGuwuUqg'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// method called by the Visualforce page's submit button</span>
    <span style="color: #000000; font-weight: bold;">public</span> PageReference submit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>address.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    		ApexPages.<span style="color: #006633;">addMessage</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ApexPages.<span style="color: #006633;">message</span><span style="color: #009900;">&#40;</span>ApexPages.<span style="color: #006633;">severity</span>.<span style="color: #006633;">ERROR</span>,<span style="color: #0000ff;">'Address cannot be blank'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #009900;">&#125;</span>
    	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>city.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    		ApexPages.<span style="color: #006633;">addMessage</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ApexPages.<span style="color: #006633;">message</span><span style="color: #009900;">&#40;</span>ApexPages.<span style="color: #006633;">severity</span>.<span style="color: #006633;">ERROR</span>,<span style="color: #0000ff;">'City cannot be blank'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #009900;">&#125;</span>
    	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>state.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    		ApexPages.<span style="color: #006633;">addMessage</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ApexPages.<span style="color: #006633;">message</span><span style="color: #009900;">&#40;</span>ApexPages.<span style="color: #006633;">severity</span>.<span style="color: #006633;">ERROR</span>,<span style="color: #0000ff;">'State cannot be blank'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #009900;">&#125;</span>
&nbsp;
    	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ApexPages.<span style="color: #006633;">hasMessages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	    	geoAddress <span style="color: #339933;">=</span> getAddress<span style="color: #009900;">&#40;</span>address,city,state<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// call the geocoding service</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> getAddress<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> street, <span style="color: #003399;">String</span> city, <span style="color: #003399;">String</span> state<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #003399;">String</span> json<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// hard-coded returned JSON response from Google</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>useGoogle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			json <span style="color: #339933;">=</span> <span style="color: #0000ff;">'{  &quot;name&quot;: &quot;1600 Amphitheatre Parkway, Mountain View, CA&quot;,  &quot;Status&quot;: {    &quot;code&quot;: 200,    &quot;request&quot;: &quot;geocode&quot;  },  &quot;Placemark&quot;: [ {    &quot;id&quot;: &quot;p1&quot;,    &quot;address&quot;: &quot;1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA&quot;,    &quot;AddressDetails&quot;: {   &quot;Accuracy&quot; : 8,   &quot;Country&quot; : {      &quot;AdministrativeArea&quot; : {         &quot;AdministrativeAreaName&quot; : &quot;CA&quot;,         &quot;SubAdministrativeArea&quot; : {            &quot;Locality&quot; : {               &quot;LocalityName&quot; : &quot;Mountain View&quot;,               &quot;PostalCode&quot; : {                  &quot;PostalCodeNumber&quot; : &quot;94043&quot;               },               &quot;Thoroughfare&quot; : {                  &quot;ThoroughfareName&quot; : &quot;1600 Amphitheatre Pkwy&quot;               }            },         '</span><span style="color: #339933;">+</span>
			<span style="color: #0000ff;">'   &quot;SubAdministrativeAreaName&quot; : &quot;Santa Clara&quot;         }      },      &quot;CountryName&quot; : &quot;USA&quot;,      &quot;CountryNameCode&quot; : &quot;US&quot;   }},    &quot;ExtendedData&quot;: {      &quot;LatLonBox&quot;: {        &quot;north&quot;: 37.4251466,        &quot;south&quot;: 37.4188514,        &quot;east&quot;: -122.0811574,        &quot;west&quot;: -122.0874526      }    },    &quot;Point&quot;: {      &quot;coordinates&quot;: [ -122.0843700, 37.4217590, 0 ]    }  } ]}	'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// call the geocoding service live</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			HttpRequest req <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Http http <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Http<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// set the method</span>
			req.<span style="color: #006633;">setMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'GET'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// generate the url for the request</span>
			<span style="color: #003399;">String</span> url <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://maps.google.com/maps/geo?q='</span><span style="color: #339933;">+</span> EncodingUtil.<span style="color: #006633;">urlEncode</span><span style="color: #009900;">&#40;</span>street,<span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">',+'</span>
				<span style="color: #339933;">+</span> EncodingUtil.<span style="color: #006633;">urlEncode</span><span style="color: #009900;">&#40;</span>city,<span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">',+'</span>
				<span style="color: #339933;">+</span> EncodingUtil.<span style="color: #006633;">urlEncode</span><span style="color: #009900;">&#40;</span>state,<span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #339933;">+</span><span style="color: #0000ff;">'&amp;output=json&amp;sensor=false&amp;key='</span><span style="color: #339933;">+</span>apiKey<span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// add the endpoint to the request</span>
			req.<span style="color: #006633;">setEndpoint</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// create the response object</span>
			HTTPResponse resp <span style="color: #339933;">=</span> http.<span style="color: #006633;">send</span><span style="color: #009900;">&#40;</span>req<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// the geocoding service is returning a line feed so parse it out</span>
			json <span style="color: #339933;">=</span> resp.<span style="color: #006633;">getBody</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span>, <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			JSONObject j <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span> json <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> toGeoResult<span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toDisplayString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JSONObject.<span style="color: #006633;">JSONException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">'Error parsing JSON response from Google: '</span><span style="color: #339933;">+</span>e<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// utility method to convert the JSON object to the inner class</span>
	<span style="color: #000000; font-weight: bold;">private</span> GeoResult toGeoResult<span style="color: #009900;">&#40;</span>JSONObject resp<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		GeoResult geo <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GeoResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			geo.<span style="color: #006633;">address</span> <span style="color: #339933;">=</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'address'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">str</span><span style="color: #339933;">;</span>
			geo.<span style="color: #006633;">keys</span> <span style="color: #339933;">=</span> resp.<span style="color: #006633;">keys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			geo.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> resp.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			geo.<span style="color: #006633;">statusCode</span> <span style="color: #339933;">=</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Status'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'code'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">num</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// set the coordinates - they may either be integers or doubles</span>
			geo.<span style="color: #006633;">coordinate1</span> <span style="color: #339933;">=</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">num</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">NULL</span> <span style="color: #339933;">?</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">num</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">dnum</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			geo.<span style="color: #006633;">coordinate2</span> <span style="color: #339933;">=</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">num</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">NULL</span> <span style="color: #339933;">?</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">num</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">dnum</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			geo.<span style="color: #006633;">coordinate3</span> <span style="color: #339933;">=</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">num</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">NULL</span> <span style="color: #339933;">?</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">num</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> resp.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Placemark'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Point'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">obj</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coordinates'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">values</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">dnum</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// #fail</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> geo<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// inner class</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">class</span> GeoResult <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> Set<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">&gt;</span> keys<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> statusCode<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> coordinate1<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> coordinate2<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> coordinate3<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> address<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> toDisplayString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> address <span style="color: #339933;">+</span> <span style="color: #0000ff;">' ['</span>
			<span style="color: #339933;">+</span> coordinate1 <span style="color: #339933;">+</span> <span style="color: #0000ff;">', '</span>
			<span style="color: #339933;">+</span> coordinate2 <span style="color: #339933;">+</span> <span style="color: #0000ff;">', '</span>
			<span style="color: #339933;">+</span> coordinate3 <span style="color: #339933;">+</span> <span style="color: #0000ff;">'] - Status: '</span>
			<span style="color: #339933;">+</span> statusCode<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The Visualforce page is fairly simple and presents the user with a form to enter their address. If the geocoding services is experiencing issues, the user can check &#8220;Use hard-coded Google JSON response?&#8221; and the Controller with use the hard-coded JSON response instead of making the GET call to the geocoding service. Once submitted, the address is processed and the outputPanel is rerendered with the resulting address and coordinates.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>page controller<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;RestDemoJsonController&quot;</span> tabStyle<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Contact&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>sectionHeader title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Google Maps Geocoding&quot;</span> subtitle<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;REST Demo (JSON)&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
     <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>form <span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlock <span style="color: #339933;">&gt;</span>
&nbsp;
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockButtons <span style="color: #339933;">&gt;</span>
              <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>commandButton action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{!submit}&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Submit&quot;</span>
                   rerender<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;resultsPanel&quot;</span> status<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;status&quot;</span><span style="color: #339933;">/&gt;</span>
          <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockButtons<span style="color: #339933;">&gt;</span>
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageMessages <span style="color: #339933;">/&gt;</span>
&nbsp;
          <span style="color: #000000; font-weight: bold;">This</span> example calls the Google <span style="color: #003399;">Map</span> geocoding REST service <span style="color: #009900;">&#40;</span>JSON<span style="color: #009900;">&#41;</span> with the address
          you provide below.<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">/&gt;</span>
&nbsp;
          Sometimes the geocoding services stops responding due to service availability. <span style="color: #000000; font-weight: bold;">If</span> you are receiving errors
          with the returned JSON object, you can check the <span style="color: #0000ff;">&quot;Use hard-coded JSON response&quot;</span> to use a returned JSON
          response hard<span style="color: #339933;">-</span>coded into the controller from the Googles address.<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">/&gt;</span>
&nbsp;
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSection <span style="color: #339933;">&gt;</span>
               <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem <span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>outputLabel <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;address&quot;</span><span style="color: #339933;">&gt;</span>Address<span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>outputLabel<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>inputText id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;address&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{!address}&quot;</span><span style="color: #339933;">/&gt;</span>
               <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem<span style="color: #339933;">&gt;</span>
          <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSection<span style="color: #339933;">&gt;</span>
&nbsp;
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSection <span style="color: #339933;">&gt;</span>
               <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem <span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>outputLabel <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;city&quot;</span><span style="color: #339933;">&gt;</span>City<span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>outputLabel<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>inputText id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;city&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{!city}&quot;</span><span style="color: #339933;">/&gt;</span>
               <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem<span style="color: #339933;">&gt;</span>
          <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSection<span style="color: #339933;">&gt;</span>
&nbsp;
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSection <span style="color: #339933;">&gt;</span>
               <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem <span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>outputLabel <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;state&quot;</span><span style="color: #339933;">&gt;</span>State<span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>outputLabel<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>inputText id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;state&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{!state}&quot;</span><span style="color: #339933;">/&gt;</span>
               <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem<span style="color: #339933;">&gt;</span>
          <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSection<span style="color: #339933;">&gt;&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSection <span style="color: #339933;">&gt;</span>
               <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem <span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>outputLabel <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;useGoogle&quot;</span><span style="color: #339933;">&gt;</span>Use hard<span style="color: #339933;">-</span>coded Google JSON response<span style="color: #339933;">?&lt;/</span>apex<span style="color: #339933;">:</span>outputLabel<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>inputCheckbox id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;useGoogle&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{!useGoogle}&quot;</span><span style="color: #339933;">/&gt;</span>
               <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSectionItem<span style="color: #339933;">&gt;</span>
          <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlockSection<span style="color: #339933;">&gt;&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>actionStatus id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;status&quot;</span> startText<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Fetching map...&quot;</span><span style="color: #339933;">/&gt;</span>
          <span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>outputPanel id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;resultsPanel&quot;</span><span style="color: #339933;">&gt;</span>
          		<span style="color: #339933;">&lt;</span>apex<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{!geoAddress}&quot;</span><span style="color: #339933;">/&gt;&lt;</span>br<span style="color: #339933;">/&gt;</span>
          <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>outputPanel<span style="color: #339933;">&gt;</span>
&nbsp;
     <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>pageBlock<span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>apex<span style="color: #339933;">:</span>page<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Unit Testing</strong></p>
<p>Writing unit tests for callouts can present a challenge. Scott Hemmeter has a really good article entitled <a href="http://sfdc.arrowpointe.com/2009/05/01/testing-http-callouts/" target="_blank">Testing HTTP Callouts</a> which should provide you with some useful techniques. You should also check out <a href="http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods" target="_blank">An Introduction to Apex Code Test Methods</a> on the developerforce wiki.</p>
<p>I also found this <a href="http://jsonviewer.stack.hu/">nifty JSON viewer</a> which makes debugging less painful.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2010/01/06/calling-a-json-rest-web-service-with-apex/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Google Wave Desktop Notifier for Windows &amp; Linux</title>
		<link>http://blog.jeffdouglas.com/2009/12/23/google-wave-desktop-notifier-for-windows-linux/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=google-wave-desktop-notifier-for-windows-linux</link>
		<comments>http://blog.jeffdouglas.com/2009/12/23/google-wave-desktop-notifier-for-windows-linux/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 13:42:13 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Wave]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1882</guid>
		<description><![CDATA[One of the main complaints regarding Google Wave is that it is yet another system to check (Gmail, Twitter, Facebook, etc.). Until (and if) Google Wave is integrated with Gmail, there are a few desktop options to notify you that you have new waves. I&#8217;ve been using the Google Wave Addon for Firefox for sometime [...]]]></description>
			<content:encoded><![CDATA[<p>One of the main complaints regarding Google Wave is that it is yet another system to check (Gmail, Twitter, Facebook, etc.). Until (and if) Google Wave is integrated with Gmail, there are a few desktop options to notify you that you have new waves. I&#8217;ve been using the <a href="https://addons.mozilla.org/en-US/firefox/addon/14973" target="_blank">Google Wave Addon for Firefox</a> for sometime but I&#8217;ve recently switched to Chrome so it&#8217;s no longer relevant.</p>
<p>The <a href="http://sourceforge.net/projects/wave-notify/" target="_blank">Google Wave Notifier</a> project on SourceForge is maturing and is available for both Windows and Linux (Wine). With the notifier you can:</p>
<div id="_mcePaste">
<ol>
<blockquote>
<li>Get real-time updates of new and changes Waves</li>
<li>See the last reply to an unread Wave</li>
<li>Quick access to your last five unread Waves</li>
<li>Automatically updates to the newest version</li>
<li>Easilly browse to an unread Wave or your inbox</li>
</blockquote>
</ol>
</div>
<p>Here a small video demonstrating some of it&#8217;s features. At <a href="http://www.appirio.com" target="_blank">Appirio</a> we are running our own domain on the Google Wave servers so it will be interesting to see if this notifier supports this feature.</p>
<p><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/wEy-83DW4Wk&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/wEy-83DW4Wk&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=wEy-83DW4Wk">www.youtube.com/watch?v=wEy-83DW4Wk</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2009/12/23/google-wave-desktop-notifier-for-windows-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Releases Google Web Toolkit 2.0</title>
		<link>http://blog.jeffdouglas.com/2009/12/09/google-releases-google-web-toolkit-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=google-releases-google-web-toolkit-2</link>
		<comments>http://blog.jeffdouglas.com/2009/12/09/google-releases-google-web-toolkit-2/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 13:12:29 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1840</guid>
		<description><![CDATA[Google released Google Web Toolkit 2.0 (GWT) yesterday with some really cool features and improvements. For those of you not familiar with GWT, it is a development toolkit for building and optimizing complex browser-based applications. You write your front-end code in Java and it is auto-magically compiled into cross browser, optimized JavaScript. GWT is used by [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/gwt"><img class="alignleft size-full wp-image-1841" style="padding-right:10px;" title="gwt-logo" src="http://jeffdonthemic.files.wordpress.com/2009/12/gwt-logo.png" alt="" width="100" height="100" /></a>Google released <a href="http://code.google.com/gwt" target="_blank">Google Web Toolkit 2.0</a> (GWT) yesterday with some really cool features and improvements. For those of you not familiar with GWT, it is a development toolkit for building and optimizing complex browser-based applications. You write your front-end code in Java and it is auto-magically compiled into cross browser, optimized JavaScript.</p>
<p>GWT is used by many products at Google, including Google Wave and Google AdWords. It&#8217;s open source, completely free, and used by thousands of developers around the world.</p>
<p>The video below does a really nice feature overview but here are some of my bullet points from the video. You can <a href="http://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html" target="_blank">find more detailed info on the new features here</a>.</p>
<ul>
<li><strong>Declarative User Interface</strong> &#8211; gone are the days of programmatically laying out your application in a Swing type manner. Similar to Adobe Flex, the new <strong>UiBinder</strong> allows you to lay out your user interface in an XML file and then bind that to a Java class that contains applications logic. This is my favorite new feature!</li>
<li><strong>Speed Tracer</strong> &#8211; a new tool that helps you analyze the performance of any web page and understand where the various sources of latency are.</li>
<li><strong>Easier Styling</strong> &#8211; with the new <strong>UiStyle</strong> feature you can write CSS styles and bundle them directly in the template. You get the speed benefit of no extra http roundtrip to fetch an external the stylesheet and prevent name conflicts across your application when using widgets.</li>
<li><strong>Predictable Performance</strong> &#8211; provide a consistent look and feel with improved layout panels that behave predictably and load quickly.</li>
<li><strong>Debug in any Browser</strong> &#8211; no more requirement to use the embedded browser when debugging Java source code. You can now debug in essentially any browser and use development tools for that browser like Firebug in Firefox.</li>
<li><strong>Faster Load Times</strong> &#8211; Developer-guided code splitting allows you to chunk your GWT code into multiple fragments for faster startup.</li>
<li><strong>Improved IDE Support</strong> &#8211; the new Eclipse plugin provides support for the UiBinder, client bundling, RPC refactoring, wizards to generate boilerplate code and the new development mode.</li>
</ul>
<p>There are a ton of additional features and you can <a href="http://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html" target="_blank">check them out here</a>. Download GWT today and get started building some kickass apps!</p>
<p><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/uExEw3OVMd0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;w=550" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/uExEw3OVMd0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1&amp;w=550" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=uExEw3OVMd0">www.youtube.com/watch?v=uExEw3OVMd0</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2009/12/09/google-releases-google-web-toolkit-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Gmail Notifier with Multiple Accounts</title>
		<link>http://blog.jeffdouglas.com/2009/11/15/using-gmail-notifier-with-multiple-accounts/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-gmail-notifier-with-multiple-accounts</link>
		<comments>http://blog.jeffdouglas.com/2009/11/15/using-gmail-notifier-with-multiple-accounts/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 15:08:29 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1683</guid>
		<description><![CDATA[I live and die by Gmail but if you are like me, and have multiple accounts, it can be a challenge to keep track of them. Google has a nifty little Gmail Notifier that runs in your menu bar but it only works for one account. My problem is that I need to track my [...]]]></description>
			<content:encoded><![CDATA[<p>I live and die by Gmail but if you are like me, and have multiple accounts, it can be a challenge to keep track of them. Google has a nifty little <a href="http://toolbar.google.com/gmail-helper/notifier_mac.html" target="_blank">Gmail Notifier</a> that runs in your menu bar but it only works for one account. My problem is that I need to track my Appirio account, personal account (I&#8217;ve used Google App for my jeffdouglas.com domain for years) and then my Gmail account.</p>
<p>Luckily there&#8217;s a way to do this by duplicating the Gmail Notifier app so that multiple copies are running. Here&#8217;s the simple process for a Mac:</p>
<ol>
<li>Right click on the Gmail Notifier application and select &#8220;Duplicate&#8221;.</li>
<li>Right click on the new Gmail Notifier application <strong>that you just created</strong> and select &#8220;Show Package Contents&#8221;.</li>
<li>Open the Info.plist file in the Contents folder in your favorite text editor (ie TextMate)</li>
<li>Find the property called CFBundleIdentifier and change it&#8217;s string value from com.google.GmailNotifier to something like com.google.GmailNotifierPersonal.</li>
<li>Now save the file and close your text editor.</li>
</ol>
<p>Now when you start all of the Gmail Notifiers, your menu bar should look like:</p>
<p><a href="http://jeffdonthemic.files.wordpress.com/2009/11/gmailnotifier.png" rel="lightbox[1683]"><img class="alignleft size-full wp-image-1684" title="GmailNotifier" src="http://jeffdonthemic.files.wordpress.com/2009/11/gmailnotifier.png" alt="GmailNotifier" width="544" height="155" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2009/11/15/using-gmail-notifier-with-multiple-accounts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Salesforce Username Tip</title>
		<link>http://blog.jeffdouglas.com/2009/10/07/salesforce-username-tip/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=salesforce-username-tip</link>
		<comments>http://blog.jeffdouglas.com/2009/10/07/salesforce-username-tip/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 10:07:01 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=1454</guid>
		<description><![CDATA[If you are like me you probably have 1.35 million Salesforce usernames. You have usernames for productions orgs, sandboxes, developer orgs, pre-release orgs, partner portals, etc. and they all must be unique. So how do you manage this chaos in a manner that doesn&#8217;t drive you insane with password resets and security tokens? If you [...]]]></description>
			<content:encoded><![CDATA[<p>If you are like me you probably have 1.35 million Salesforce usernames. You have usernames for productions orgs, sandboxes, developer orgs, pre-release orgs, partner portals, etc. and they all <strong>must be unique</strong>. So how do you manage this chaos in a manner that doesn&#8217;t drive you insane with password resets and security tokens?</p>
<p>If you are using Gmail or Google Apps there is a easy way to manage your Salesforce usernames using address aliases. For instance, if your email address is coolsalesforceguy@gmail.com, you can add a &#8220;+&#8221; and some sort of identifier to your Gmail address to create unique email addresses that are delivered to your one Gmail inbox. Therefore, you could do things like:</p>
<ul>
<li>coolsalesforceguy+prd@gmail.com</li>
<li>coolsalesforceguy+sandbox1@gmail.com</li>
<li>coolsalesforceguy+de7@gmail.com</li>
<li>coolsalesforceguy+customer1prd@gmail.com</li>
</ul>
<p>You can then set up filters to automatically direct these messages to Trash, apply a label or star, skip the inbox, or forward to another email account.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2009/10/07/salesforce-username-tip/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
