<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>/home/nick</title>
	
	<link>http://whatwouldnickdo.com/wordpress</link>
	<description>Discussions on Programming, Linux, and whatever else.</description>
	<lastBuildDate>Sun, 22 Aug 2010 14:56:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/whatwouldnickdo" /><feedburner:info uri="whatwouldnickdo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Net Scan – Android App for Network Discovery and Port Scanning.</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/1ARYvUdc5U4/</link>
		<comments>http://whatwouldnickdo.com/wordpress/559/android-net-scan-port-scan/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 14:56:06 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=559</guid>
		<description><![CDATA[Not just another android port scan app. Net Scan strives to be the fastest one out there. On top of just scanning ports, Net Scan also utilizes network discovery to scan an entire network for IP aware devices (fancy for computers, routers, smartphones, printers, scanners, gaming consoles, or whatever). Once a list of devices is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="market://details?id=com.wwnd.netmapper"><img src="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2010/08/netscan-300x300.png" alt="" title="Net Scan" width="300" height="300" class="alignright size-medium wp-image-562" /></a>Not just another <a href="http://www.android.com/">android</a> port scan app.  <a href="market://details?id=com.wwnd.netmapper">Net Scan</a> strives to be the fastest one out there.  On top of just scanning ports, Net Scan also utilizes network discovery to scan an entire network for IP aware devices (fancy for computers, routers, smartphones, printers, scanners, gaming consoles, or whatever).  Once a list of devices is found, they can be clicked on to run a port scan.<br />
<span id="more-559"></span><br />
When I first started coding this app, I tried to list some of the more annoying usability issues common in a lot of mobile and non-mobile apps. The last thing you want to have to do on a phone is type anything you don’t have to.  Sure there’s always going to be one or two scenarios in which you’re going to HAVE to type in parameters, but they were avoided at all costs using smart selections and field auto-population.  For instance, when running a simple port scan on a machine, instead of giving a blank field to enter an ip address the user is instead given a field with an address already populated that’s relevant to the network they’re on.  Instead of having to type in whole addresses, the user can just backspace on the last few digits and replace them.  Sure this might sound small, but in the world of mobile devices, any help the user gets with inputting data is huge.<br />
<a href="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2010/08/netscan03.jpeg"><img src="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2010/08/netscan03.jpeg" alt="" title="Net Scan on Android" width="600" height="516" class="aligncenter size-full wp-image-571" /></a><br />
In addition to the lightning fast port scan there’s also a Quick Scan feature which scans for a small set of widely used ports. This scan is almost instant and is great when you need to go down the list to see which computers on the network have ssh or http open. There are a lot of future plans to make this Quick Scan option flexible and fully configurable.</p>
<p>More features are on the way.</p>
<p>This is my first android app.  I’m developing on the <a href="http://en.wikipedia.org/wiki/Motorola_Droid">Motorola Droid</a>, but if anyone has issues on other phones please leave me a comment.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/_M3QQqywLXGBBwcspE9_hlkDVYE/0/da"><img src="http://feedads.g.doubleclick.net/~a/_M3QQqywLXGBBwcspE9_hlkDVYE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_M3QQqywLXGBBwcspE9_hlkDVYE/1/da"><img src="http://feedads.g.doubleclick.net/~a/_M3QQqywLXGBBwcspE9_hlkDVYE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/1ARYvUdc5U4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/559/android-net-scan-port-scan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/559/android-net-scan-port-scan/</feedburner:origLink></item>
		<item>
		<title>Calling multiple methods from one RemoteObject in Flex and Actionscript using BlazeDS</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/txWzR2yZngI/</link>
		<comments>http://whatwouldnickdo.com/wordpress/532/calling-multiple-methods-from-one-remoteobject-in-flex-and-actionscript-using-blazeds/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 20:22:36 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[web-dev]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[BlazeDS]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=532</guid>
		<description><![CDATA[BlazeDS allows us to use RPC to access our Java objects from an Adobe Flex or AIR app. This is a simple example that allows you to have a remote java object which you will make calls upon from Flex (or Actionscript). There are plenty of BlazeDS remoting tutorials out there. This HOW-TO shows how [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/BlazeDS">BlazeDS</a> allows us to use <a href="http://en.wikipedia.org/wiki/Remote_procedure_call">RPC</a> to access our <a href="http://en.wikipedia.org/wiki/Java_(programming_language)">Java</a> objects from an <a href="http://en.wikipedia.org/wiki/Adobe_Flex">Adobe Flex</a> or <a href="http://en.wikipedia.org/wiki/Adobe_Apollo">AIR</a> app.  This is a simple example that allows you to have a remote java object which you will make calls upon from Flex (or <a href="http://en.wikipedia.org/wiki/ActionScript">Actionscript</a>).   There are plenty of BlazeDS remoting tutorials out there.  This HOW-TO shows how to create an actionscript class to handle your remote objects and handlers as well as linking more than one method to a single remote object.<br />
<span id="more-532"></span><br />
This HOW-TO assumes you have the knowledge to create a small flex app and a server-side java project using BlazeDS.  If you don&#8217;t know how to do this, there are tons of tutorials out there like <a href="http://codeofdoom.com/wordpress/2009/02/01/blazeds-with-remote-objects-example/">this one</a>.</p>
<p>Here&#8217;s the java object that we&#8217;ll be calling methods on from Flex:</p>

<div class="wp_syntax"><div 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> MyRemoteService <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> MyRemoteService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getSessionId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> sessionId <span style="color: #339933;">=</span> FlexContext.<span style="color: #006633;">getFlexSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;returning sessionId &quot;</span><span style="color: #339933;">+</span>sessionId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> sessionId<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getMyData<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> stuff from database or whatever
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Our <a href="http://livedocs.adobe.com/flex/3/langref/mx/rpc/remoting/mxml/RemoteObject.html">RemoteObject</a> will be called remoteService and will call the two methods <strong>getSessionId()</strong> and <strong>getMyData()</strong>.  The following is the <a href="http://en.wikipedia.org/wiki/MXML">mxml</a> for remoteService that has the two methods.  Each method has a name attribute and attributes to set handlers for a <strong>fault</strong> and <strong>result</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="flex" style="font-family:monospace;">&lt;mx:RemoteObject id=&quot;remoteService&quot; destination=&quot;remoteServiceDestination&quot;&gt;
	&lt;mx:method name=&quot;getSessionId&quot; fault=&quot;handler_getSessionIdFault(event)&quot; result = &quot;handler_getSessionIdSuccess(event)&quot; /&gt;
	&lt;mx:method name=&quot;getMyData&quot;    fault=&quot;handler_getMyDataFault(event)&quot;    result = &quot;handler_getMyDataSuccess(event)&quot; /&gt;
&lt;/mx:RemoteObject&gt;</pre></div></div>

<p>This next code block does the same thing as our above code, except it&#8217;s an actionscript class.  It handles the same two methods.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ConnectionManager
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FaultEvent</span>; 
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">Responder</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">remoting</span>.<span style="color: #006600;">mxml</span>.<span style="color: #006600;">RemoteObject</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">Channel</span>; 
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">ChannelSet</span>; 
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">channels</span>.<span style="color: #006600;">AMFChannel</span>;  
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> blazeUrl:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;http://localhost:8080/BlazeServer/messagebroker/&quot;</span>;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> remoteService:RemoteObject = <span style="color: #000000; font-weight: bold;">new</span> RemoteObject;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ConnectionManager<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> cs:ChannelSet = <span style="color: #000000; font-weight: bold;">new</span> ChannelSet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
		<span style="color: #000000; font-weight: bold;">var</span> myAMF:Channel = <span style="color: #000000; font-weight: bold;">new</span> AMFChannel<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;my-amf&quot;</span>, blazeUrl + <span style="color: #ff0000;">&quot;amf&quot;</span><span style="color: #66cc66;">&#41;</span>; 
		cs.<span style="color: #006600;">addChannel</span><span style="color: #66cc66;">&#40;</span>myAMF<span style="color: #66cc66;">&#41;</span>; 
		remoteService.<span style="color: #006600;">channelSet</span> = cs; 
&nbsp;
		remoteService.<span style="color: #006600;">destination</span> = <span style="color: #ff0000;">&quot;remoteServiceDestination&quot;</span>;
		remoteService.<span style="color: #006600;">showBusyCursor</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #000000; font-weight: bold;">var</span> rpcCall:AsyncToken;
&nbsp;
		rpcCall = remoteService.<span style="color: #006600;">getSessionId</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		rpcCall.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>handler_getSessionIdSuccess, handler_getSessionIdFault<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
		rpcCall = remoteService.<span style="color: #006600;">getMyData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		rpcCall.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>handler_getMyDataSuccess, handler_getMyDataFault<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handler_getSessionIdSuccess<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;sessionId: &quot;</span>+event.<span style="color: #0066CC;">message</span>.<span style="color: #006600;">body</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getSessionIdSuccess&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handler_getSessionIdFault<span style="color: #66cc66;">&#40;</span>fault:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>fault<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>fault.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getSessionIdFault&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handler_getMyDataSuccess<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #0066CC;">message</span>.<span style="color: #006600;">body</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getMyDataSuccess&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handler_getMyDataFault<span style="color: #66cc66;">&#40;</span>fault:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>fault<span style="color: #66cc66;">&#41;</span>;
		Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>fault.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;handler_getMyDataFault&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>For a good book about Flex check out <a href="http://www.amazon.com/gp/product/1933988746?ie=UTF8&#038;tag=homenick-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1933988746">Flex 3 in Action</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=as2&#038;o=1&#038;a=1933988746" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>

<p><a href="http://feedads.g.doubleclick.net/~a/YmPADGsUPAnDRO66s1lKCcw1dwI/0/da"><img src="http://feedads.g.doubleclick.net/~a/YmPADGsUPAnDRO66s1lKCcw1dwI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/YmPADGsUPAnDRO66s1lKCcw1dwI/1/da"><img src="http://feedads.g.doubleclick.net/~a/YmPADGsUPAnDRO66s1lKCcw1dwI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/txWzR2yZngI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/532/calling-multiple-methods-from-one-remoteobject-in-flex-and-actionscript-using-blazeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/532/calling-multiple-methods-from-one-remoteobject-in-flex-and-actionscript-using-blazeds/</feedburner:origLink></item>
		<item>
		<title>Looping Sound in Flex and AIR</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/qE1kCEjtaPA/</link>
		<comments>http://whatwouldnickdo.com/wordpress/509/looping-sound-in-flex-and-air/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 20:10:48 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[web-dev]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=509</guid>
		<description><![CDATA[This is a short example of how to play an audio clip and loop it in Flex, and works with AIR. Some of this code is taken from the Sound class example in the Adobe Flex Language Reference docs. You can paste this into pretty much any function, like an init(): var soundReq:URLRequest = new [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short example of how to play an audio clip and loop it in <a href="http://www.adobe.com/products/flex/">Flex</a>, and works with <a href="http://www.adobe.com/products/air/">AIR</a>.  Some of this code is taken from the <a href="http://livedocs.adobe.com/flex/3/langref/flash/media/Sound.html">Sound</a> class example in the Adobe Flex Language Reference docs.</p>
<p>You can paste this into pretty much any function, like an init():</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> soundReq:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;someSound.mp3&quot;</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">sound</span>:<span style="color: #0066CC;">Sound</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Sound</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #000000; font-weight: bold;">var</span> soundControl:SoundChannel = <span style="color: #000000; font-weight: bold;">new</span> SoundChannel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #0066CC;">sound</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, completeHandler<span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">sound</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #0066CC;">ID3</span>, id3Handler<span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">sound</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, ioSoundErrorHandler<span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">sound</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ProgressEvent.<span style="color: #006600;">PROGRESS</span>, progressHandler<span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">sound</span>.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>soundReq<span style="color: #66cc66;">&#41;</span>; 
soundControl = <span style="color: #0066CC;">sound</span>.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">int</span>.<span style="color: #0066CC;">MAX_VALUE</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><span id="more-509"></span><br />
Notice the line:<br />
<strong>sound.play(0, int.MAX_VALUE);  </strong><br />
The second parameter is the number of times to loop.  Set it to zero to play the sound one time.  There&#8217;s no real way (that I have found) to play the audio infinite times, so I put in int.MAX_VALUE which is a 32-bit signed integer of the value 2,147,483,647.   Sure this won&#8217;t loop forever, but given a one second audio clip it would loop for about 68 years!</p>
<p>Here&#8217;s the handlers to go along with it:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> completeHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;completeHandler: &quot;</span> + event<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> ioSoundErrorHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ioSoundErrorHandler: &quot;</span> + event<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> id3Handler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;id3Handler: &quot;</span> + event<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> progressHandler<span style="color: #66cc66;">&#40;</span>event:ProgressEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;progressHandler: &quot;</span> + event<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I&#8217;m still new to Flex so if anyone notices anything that isn&#8217;t right, please let me know.  Also if anyone is looking for a decent BlazeDS tutorial, I&#8217;ve found one <a href="http://codeofdoom.com/wordpress/2009/01/29/blazeds-data-push-with-remote-objects/">here</a>.  Also been reading <a href="http://www.amazon.com/gp/product/0596516215?ie=UTF8&#038;tag=homenick-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596516215">Programming Flex 3: The Comprehensive Guide to Creating Rich Internet Applications with Adobe Flex</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=as2&#038;o=1&#038;a=0596516215" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> which isn&#8217;t bad, if anyone else recommends a book let me know.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/EaM8dYlkVEMUbOowNAmx5mufe9A/0/da"><img src="http://feedads.g.doubleclick.net/~a/EaM8dYlkVEMUbOowNAmx5mufe9A/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EaM8dYlkVEMUbOowNAmx5mufe9A/1/da"><img src="http://feedads.g.doubleclick.net/~a/EaM8dYlkVEMUbOowNAmx5mufe9A/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/qE1kCEjtaPA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/509/looping-sound-in-flex-and-air/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/509/looping-sound-in-flex-and-air/</feedburner:origLink></item>
		<item>
		<title>iBatis – Mapping Database NULL</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/VcfVAhb-QhI/</link>
		<comments>http://whatwouldnickdo.com/wordpress/491/ibatis-mapping-database-null/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 00:49:14 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[iBatis]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=491</guid>
		<description><![CDATA[iBatis is a framework used to map a SQL database to POJOs (Plain Old Java Objects).&#160; iBatis is one framework of many out there, others include Hibernate.&#160; Recently I&#8217;ve been tasked with a new webapp which will connect to a very old legacy database.&#160; One of the first things I decided to do was look [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ibatis.apache.org/">iBatis</a> is a framework used to map a SQL database to <a href="http://en.wikipedia.org/wiki/POJO">POJOs</a> (Plain Old Java Objects).&nbsp; iBatis is one framework of many out there, others include <a href="http://www.hibernate.org/">Hibernate</a>.&nbsp; Recently I&#8217;ve been tasked with a new webapp which will connect to a very old legacy database.&nbsp; One of the first things I decided to do was look through the database and figure out what data I needed, and then design and create java objects to hold said data.&nbsp; I chose iBatis for this particular project because I was dealing with a legacy database which I had little control over, and iBatis can give me the flexibility I need in case I need to write complex and specific SQL to construct my objects.&nbsp; <br />
<span id="more-491"></span><br />
<strong><span style="font-size: medium;">The issue:</span></strong><br />
One thing I noticed about the database was that there are NULLs littered everywhere, and using a default value for columns was barely used at all.&nbsp; So there are plenty of columns with a data type of <strong>int</strong>, <strong>float</strong> and <strong>bit</strong> (I&#8217;m using a MS SQL Server database) that have NULLs in there.&nbsp; Now, if I was recoding other applications that updated and inserted into these places, I would have checked data and inserted a default value, as well as maybe altering the column to allow no NULLs and set a default value, but I can&#8217;t do that.&nbsp; These tables I&#8217;m using will get mapped to a POJO, and of course I want the ints and booleans in the database mapped to ints and booleans in my POJO.&nbsp; But what happens if one of those database ints or booleans has a NULL?&nbsp; Well, java will try to set the int or boolean to a null (which can&#8217;t be done) and it throws an exception instead&#8230;an <strong>IllegalArgumentException</strong> to be exact.</p>
<p><strong><span style="font-size: medium;">The quick fix:</span></strong><br />
Going through the iBatis docs can sometimes be tedious.&nbsp; Fortunately, the solution is simple.&nbsp; If you open your xml file dealing with the object in question, and go to your <strong>resultMap</strong> element for the class, you&#8217;ll typically have a <strong>result</strong> element for each column you&#8217;re dealing with.&nbsp; Add an attribute called <strong>nullValue</strong> with a value to give the object in question in case a NULL is present.&nbsp; It&#8217;s that simple.&nbsp; </p>
<p><strong><span style="font-size: medium;">Here&#8217;s an example&#8230;</span></strong><br />
You have a table called Employee with several columns and create a POJO like below to hold that data:</p>

<div class="wp_syntax"><div 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> Employee <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> id<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> login<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> password<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> authorityType<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span> passwordExpired<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// ... constructors and setter/getter methods here...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
Let&#8217;s say that authorityType and passwordExpired were NULL values in the database.&nbsp; Adding the nullValue attribute to the xml file like so would solve your issue:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resultMap</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;EmployeeResult&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Employee&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;result</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;id&quot;</span>              <span style="color: #000066;">column</span>=<span style="color: #ff0000;">&quot;id&quot;</span>                               <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;result</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;login&quot;</span>           <span style="color: #000066;">column</span>=<span style="color: #ff0000;">&quot;login&quot;</span>                            <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;result</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;password&quot;</span>        <span style="color: #000066;">column</span>=<span style="color: #ff0000;">&quot;password&quot;</span>                         <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;result</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;authorityType&quot;</span>   <span style="color: #000066;">column</span>=<span style="color: #ff0000;">&quot;authorityType&quot;</span>   <span style="color: #000066;">nullValue</span>=<span style="color: #ff0000;">&quot;1&quot;</span>    <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;result</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;passwordExpired&quot;</span> <span style="color: #000066;">column</span>=<span style="color: #ff0000;">&quot;passwordExpired&quot;</span> <span style="color: #000066;">nullValue</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resultMap<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p><a href="http://feedads.g.doubleclick.net/~a/Sokg-s_4jybQoWuvOPa05rFQJv8/0/da"><img src="http://feedads.g.doubleclick.net/~a/Sokg-s_4jybQoWuvOPa05rFQJv8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Sokg-s_4jybQoWuvOPa05rFQJv8/1/da"><img src="http://feedads.g.doubleclick.net/~a/Sokg-s_4jybQoWuvOPa05rFQJv8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/VcfVAhb-QhI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/491/ibatis-mapping-database-null/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/491/ibatis-mapping-database-null/</feedburner:origLink></item>
		<item>
		<title>Wicked Cool PHP – Review</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/-Q02Crfw5sw/</link>
		<comments>http://whatwouldnickdo.com/wordpress/465/wicked-cool-php-review/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 21:49:20 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=465</guid>
		<description><![CDATA[I&#8217;ve been reading tons of books lately, mostly to do research into technologies I&#8217;m thinking about trying out. I have several projects going on and I&#8217;m primarily a java developer. For a new project I just started last week I&#8217;ve decided to give it a go using PHP, which I&#8217;ve never touched before. My main [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/1593271735?ie=UTF8&#038;tag=homenick-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1593271735"><img border="0" style="float: right;" src="http://whatwouldnickdo.com/wordpress/blog-attachments/512ppzO2mGL._SL160_.jpg"></a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=as2&#038;o=1&#038;a=1593271735" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />I&#8217;ve been reading tons of books lately, mostly to do research into technologies I&#8217;m thinking about trying out. I have several projects going on and I&#8217;m primarily a java developer. For a new project I just started last week I&#8217;ve decided to give it a go using <a id="o8if" title="PHP" href="http://en.wikipedia.org/wiki/Php">PHP</a>, which I&#8217;ve never touched before. My main reason for this was, from what I hear, that PHP is good for simple projects that need a fast turn around. This is exactly what I&#8217;m looking for, in addition to integrating with <a id="ovdo" title="wordpress" href="http://wordpress.org/">wordpress</a>.  I starting going through a bunch of lame tutorials on the web, but they&#8217;re mostly geared for a beginner and there&#8217;s a lot I can skip over. I decided to get a couple of recommended books on PHP and one that I found very useful is called <a href="http://www.amazon.com/gp/product/1593271735?ie=UTF8&#038;tag=homenick-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1593271735">Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=as2&#038;o=1&#038;a=1593271735" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />by William Steinmetz with Brian Ward.<br />
<span id="more-465"></span><br />
<strong>Why this book is useful</strong></p>
<p>Sure I need to see basics on the PHP syntax, but nothing in depth and not a million pages covering if/then, looping, etc. What I need to know is:</p>
<ul>
<li> how can I quickly parse some <a id="wbr:" title="XML" href="http://en.wikipedia.org/wiki/Xml">XML</a></li>
<li> how can I read and parse a file from a web URL</li>
<li> basics on session handling</li>
<li> how to select some <a id="i.5l" title="mySQL" href="http://www.mysql.com/">mySQL</a> database rows</li>
<li> a rundown on security and making a PHP app more secure</li>
</ul>
<p>This book covered all of this with nice clean short examples.  One of the things that I also like about this book is the layout.  It&#8217;s kind of setup like a cookbook, so you don&#8217;t have to read straight through front to back (although I did).  If you want to read up on manipulating images and <a id="ylcq" title="CAPTCHA" href="http://en.wikipedia.org/wiki/Captcha">CAPTCHA</a> you can flip to that section and you won&#8217;t feel confused because you skipped several chapters.  Hands down the best chapter in the book is <strong>Chapter 3 PHP Security</strong>.  This chapter discusses hashing, <a id="w3qp" title="SQL injection" href="http://en.wikipedia.org/wiki/SQL_injection">SQL injection</a> , and <a id="j0ng" title="XSS attacks" href="http://en.wikipedia.org/wiki/Cross-site_scripting">XSS attacks</a> , but this chapter also has the most important section in the book title &#8220;<strong>Recommended Security Configuration Options</strong>&#8220;.  This, less than a page, section was a bulleted list of what you need to change in your php.ini to get your PHP installation ready to run on a production server.  This was gold.</p>
<p><strong>Who should read this book</strong></p>
<p>If you&#8217;re new to programming then this probably isn&#8217;t the book for you.  In fact, if you&#8217;re new to PHP it may not be the book for you.  This book is for intermediate PHP developers that want to get things done fast.  All in all I give the book a <strong>5 out of 5</strong> because not only is it a good learning tool but becomes a great reference book.  If I had to pick a weak point it would be the last chapter which gave several large examples to pull the book&#8217;s code together, which might be what others like but wasn&#8217;t what I needed.</p>
<p>Lastly, if anyone can recommend some good books on frameworks (MVC or other) for PHP to use with larger projects, please leave a comment with the book name.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/t4k2qEs2O6__lW3IFc-gGcpuREI/0/da"><img src="http://feedads.g.doubleclick.net/~a/t4k2qEs2O6__lW3IFc-gGcpuREI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/t4k2qEs2O6__lW3IFc-gGcpuREI/1/da"><img src="http://feedads.g.doubleclick.net/~a/t4k2qEs2O6__lW3IFc-gGcpuREI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/-Q02Crfw5sw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/465/wicked-cool-php-review/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/465/wicked-cool-php-review/</feedburner:origLink></item>
		<item>
		<title>Quick Tomcat https SSL Config</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/PbGzF7bawzA/</link>
		<comments>http://whatwouldnickdo.com/wordpress/431/quick-tomcat-https-ssl-config/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 19:04:52 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[web-dev]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=431</guid>
		<description><![CDATA[Setting up your webapp to work with https and SSL encryption when using Tomcat is easier than most people think.  Here&#8217;s a very quick HOW-TO to get you up and running&#8230; The first thing you need to do is create a certificate.  If you&#8217;re unfamiliar with certificates or SSL you can look at some of [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up your webapp to work with <a href="http://en.wikipedia.org/wiki/Https">https and SSL encryption</a> when using <a href="http://tomcat.apache.org/">Tomcat</a> is easier than most people think.  Here&#8217;s a very quick HOW-TO to get you up and running&#8230;<br />
<span id="more-431"></span><br />
The first thing you need to do is create a <a href="http://en.wikipedia.org/wiki/Certificate_Authority">certificate</a>.  If you&#8217;re unfamiliar with certificates or SSL you can look at some of the following links to help school you:<br />
<a href="http://tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html">http://tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html</a><br />
<a href="http://www.ourshop.org/resources/ssl.html">http://www.ourshop.org/resources/ssl.html </a><br />
<a href="http://www.wisegeek.com/what-is-the-difference-between-http-and-https.htm">http://www.wisegeek.com/what-is-the-difference-between-http-and-https.htm</a></p>
<p><strong>Creating your certificate</strong></p>
<ul>
<li>Go to your JRE bin folder and there will be a file called &#8220;keytool&#8221;.</li>
<li>Type <strong>keytool -genkey -alias tomcat -keyalg RSA -keystore c:/.keystore</strong> The &#8220;keystore&#8221; parameter is optional.  It&#8217;s the location where the certificate keystore will be stored.  By default it will be stored in the current user&#8217;s home directory.</li>
<li>Upon executing, you will be prompted with a number of questions like name, location, organization, etc.  For name I recommend using the domain or if need be the machine name.</li>
</ul>
<p><strong>Modifying the server.xml file</strong></p>
<ul>
<li>Locate the server.xml in $CATALINA_HOME/conf/server.xml</li>
<li>Open it and look for a section dealing with the SSL Connector.  The section will look something like this:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">&lt;Connector </span>
<span style="color: #808080; font-style: italic;">           port=&quot;8443&quot; minProcessors=&quot;5&quot; maxProcessors=&quot;75&quot;</span>
<span style="color: #808080; font-style: italic;">           enableLookups=&quot;true&quot; disableUploadTimeout=&quot;true&quot;</span>
<span style="color: #808080; font-style: italic;">           acceptCount=&quot;100&quot; debug=&quot;0&quot; scheme=&quot;https&quot; secure=&quot;true&quot;;</span>
<span style="color: #808080; font-style: italic;">           clientAuth=&quot;false&quot; sslProtocol=&quot;TLS&quot;/&gt;</span>
<span style="color: #808080; font-style: italic;">--&gt;</span></pre></div></div>

<ul>
<li>Uncomment the block, and add in another attribute  for the keystore location.  We&#8217;ll add in <strong>keystoreFile=&#8221;c:\.keystore&#8221;</strong>, so when finished we&#8217;ll have:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt;-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Connector</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">port</span>=<span style="color: #ff0000;">&quot;8443&quot;</span> <span style="color: #000066;">minProcessors</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">maxProcessors</span>=<span style="color: #ff0000;">&quot;75&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">enableLookups</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">disableUploadTimeout</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">acceptCount</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">debug</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">scheme</span>=<span style="color: #ff0000;">&quot;https&quot;</span> <span style="color: #000066;">secure</span>=<span style="color: #ff0000;">&quot;true&quot;</span>;</span>
<span style="color: #009900;">           <span style="color: #000066;">clientAuth</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">sslProtocol</span>=<span style="color: #ff0000;">&quot;TLS&quot;</span> <span style="color: #000066;">keystoreFile</span>=<span style="color: #ff0000;">&quot;c:\.keystore&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Connector<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>For full workings of server.xml refer to the <a href="http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html">apache site</a>.   </p>
<p>Last step is to restart Tomcat and point the browser to:<br />
<strong>https://localhost:8443 </strong><br />
Remember the <strong>https</strong> and it uses port 8443 by default which can be changed in the server.xml</p>

<p><a href="http://feedads.g.doubleclick.net/~a/M1Lut_zEhwPE-s6soptiMfk7W2Y/0/da"><img src="http://feedads.g.doubleclick.net/~a/M1Lut_zEhwPE-s6soptiMfk7W2Y/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/M1Lut_zEhwPE-s6soptiMfk7W2Y/1/da"><img src="http://feedads.g.doubleclick.net/~a/M1Lut_zEhwPE-s6soptiMfk7W2Y/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/PbGzF7bawzA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/431/quick-tomcat-https-ssl-config/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/431/quick-tomcat-https-ssl-config/</feedburner:origLink></item>
		<item>
		<title>Performance: Grid vs FlexTable</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/5sNH8HuwiDA/</link>
		<comments>http://whatwouldnickdo.com/wordpress/401/performance-grid-vs-flextable/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 23:22:00 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=401</guid>
		<description><![CDATA[I&#8217;ve been having some problems in GWT with a table pulling 100+ rows at a reasonable speed using the FlexTable, but before making massive changes by switching to a Grid I ran some tests comparing the two.&#160; I originally found this issue when testing on IE for the first time after having no problems with [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having some problems in <a href="http://code.google.com/webtoolkit/">GWT</a> with a table pulling 100+ rows at a reasonable speed using the FlexTable, but before making massive changes by switching to a Grid I ran some tests comparing the two.&nbsp; I originally found this issue when testing on <a href="http://en.wikipedia.org/wiki/Internet_Explorer">IE</a> for the first time after having no problems with <a href="http://www.mozilla.com/en-US/firefox/">FF</a>.&nbsp; <br />
<span id="more-401"></span></p>
<p>Here&#8217;s the basic code used:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">long</span> startTime <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> names.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    NameData nd <span style="color: #339933;">=</span> names<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    grid.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">0</span>, nd.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    grid.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">1</span>, <span style="color: #003399;">Double</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>nd.<span style="color: #006633;">getD1</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    grid.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">2</span>, <span style="color: #003399;">Double</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>nd.<span style="color: #006633;">getD2</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    grid.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">3</span>, <span style="color: #003399;">Integer</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>nd.<span style="color: #006633;">getRank</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
gridLabel.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Grid: &quot;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>startTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
startTime <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> names.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    NameData nd <span style="color: #339933;">=</span> names<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    flex.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">0</span>, nd.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    flex.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">1</span>, <span style="color: #003399;">Double</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>nd.<span style="color: #006633;">getD1</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    flex.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">2</span>, <span style="color: #003399;">Double</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>nd.<span style="color: #006633;">getD2</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    flex.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">3</span>, <span style="color: #003399;">Integer</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>nd.<span style="color: #006633;">getRank</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
flexLabel.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FlexTable: &quot;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>startTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I&#8217;m pulling from an array of 100 which holds some data that&#8217;s used to populate the cells.&nbsp; The creation of the tables is done before hand, I&#8217;m not sure if this gives an unfair advantage to the Grid, but that&#8217;s the way I&#8217;m doing it.</p>
<p>Try the <a title="test app yourself here" href="http://whatwouldnickdo.com/gridvflex/GridVFlex.html" id="ojdg">test app yourself here</a> .<br />
<span><br />
</span><span><b>Results</b><br />
What I&#8217;m finding is that the Grid does beat the FlexTable, but not by much with a small data set.&nbsp; Larger sets seem to widen the gap.&nbsp; My guess for this is that since FlexTable has the ability to add rows (Grid is sized from the start) that it works much like how other resizable constructs work such as Java&#8217;s ArrayList. My reasoning for this is that the first time the test is run the speed is very slow on the FlexTable (especially in IE).&nbsp; Repeated test runs after the initial are faster and I think this is because the table was being sized the first time as rows were added, and didn&#8217;t need to be resized during the following tests. </p>
<p>The other thing I&#8217;m finding is that performace varies based on browser.&nbsp; I&#8217;m seeing FF run reasonably well.&nbsp; With IE the Grid runs about the same as FF but the FlexTable runs considerably slower.&nbsp; I also tested Opera and was stunned as it blew both others out of the water.&nbsp; </p>
<p>Here&#8217;s some of the tests run with two different machines (one linux and one Windows):</p>
<p>
</span><b><span>MS Windows Machine </span></b><br />
<span></p>
<div>
<table class="zeroBorder" id="m.j4" width="400" border="1" bordercolor="#444444" cellpadding="3" cellspacing="0" height="125">
<tbody>
<tr>
<td width="20%">
</td>
<td width="20%" bgcolor="#d0e0e3">FF
</td>
<td width="20%" bgcolor="#d0e0e3">FF
</td>
<td width="20%" bgcolor="#d0e0e3">IE
</td>
<td width="20%" bgcolor="#d0e0e3">IE
</td>
</tr>
<tr align="right">
<td width="20%">
</td>
<td width="20%" bgcolor="#d0e0e3">Grid
</td>
<td width="20%" bgcolor="#d0e0e3">FlexTable
</td>
<td width="20%" bgcolor="#d0e0e3">Grid
</td>
<td width="20%" bgcolor="#d0e0e3">FlexTable
</td>
</tr>
<tr>
<td width="20%" bgcolor="#d0e0e3">Run 1
</td>
<td width="20%" align="right">147ms
</td>
<td width="20%" align="right">198ms
</td>
<td width="20%" align="right">156ms
</td>
<td width="20%" align="right">1297ms
</td>
</tr>
<tr>
<td width="20%" bgcolor="#d0e0e3">Run 2
</td>
<td width="20%" align="right">131ms
</td>
<td width="20%" align="right">158ms
</td>
<td width="20%" align="right">156ms
</td>
<td width="20%" align="right">203ms
</td>
</tr>
<tr>
<td width="20%" bgcolor="#d0e0e3">Run 3
</td>
<td width="20%" align="right">150ms
</td>
<td width="20%" align="right">176ms
</td>
<td width="20%" align="right">156ms
</td>
<td width="20%" align="right">172ms
</td>
</tr>
</tbody>
</table>
</div>
<p>
</span><b>Linux Machine</b><br />
<span></span><span></span></p>
<div>
<table class="zeroBorder" id="o4n2" width="400" border="1" bordercolor="#444444" cellpadding="3" cellspacing="0" height="125">
<tbody>
<tr>
<td width="20%">
</td>
<td width="20%" bgcolor="#d0e0e3">FF
</td>
<td width="20%" bgcolor="#d0e0e3">FF
</td>
<td width="20%" bgcolor="#d0e0e3">Opera
</td>
<td width="20%" bgcolor="#d0e0e3">Opera
</td>
</tr>
<tr>
<td width="20%">
</td>
<td width="20%" bgcolor="#d0e0e3">Grid
</td>
<td width="20%" bgcolor="#d0e0e3">FlexTable
</td>
<td width="20%" bgcolor="#d0e0e3">Grid
</td>
<td width="20%" bgcolor="#d0e0e3">FlexTable
</td>
</tr>
<tr>
<td width="20%" bgcolor="#d0e0e3">Run 1
</td>
<td width="20%" align="right">89ms
</td>
<td width="20%" align="right">244ms
</td>
<td width="20%" align="right">37ms
</td>
<td width="20%" align="right">118ms
</td>
</tr>
<tr>
<td width="20%" bgcolor="#d0e0e3">Run 2
</td>
<td width="20%" align="right">85ms
</td>
<td width="20%" align="right">115ms
</td>
<td width="20%" align="right">31ms
</td>
<td width="20%" align="right">41ms
</td>
</tr>
<tr>
<td width="20%" bgcolor="#d0e0e3">Run 3
</td>
<td width="20%" align="right">86ms
</td>
<td width="20%" align="right">115ms
</td>
<td width="20%" align="right">28ms
</td>
<td width="20%" align="right">41ms
</td>
</tr>
</tbody>
</table>
</div>
<p><span></span></p>
<p></p>

<p><a href="http://feedads.g.doubleclick.net/~a/t0Ckkk0WR2VrK546wjb__iZAOfc/0/da"><img src="http://feedads.g.doubleclick.net/~a/t0Ckkk0WR2VrK546wjb__iZAOfc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/t0Ckkk0WR2VrK546wjb__iZAOfc/1/da"><img src="http://feedads.g.doubleclick.net/~a/t0Ckkk0WR2VrK546wjb__iZAOfc/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/5sNH8HuwiDA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/401/performance-grid-vs-flextable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/401/performance-grid-vs-flextable/</feedburner:origLink></item>
		<item>
		<title>GWT Right-click Context Menu</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/OtK8RqFkFhY/</link>
		<comments>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 01:12:27 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web-dev]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370</guid>
		<description><![CDATA[The Google Web Toolkit has been out for a while now, and yet there is still basic functionality that is missing from the toolkit.  Don&#8217;t get me started on the lack of draggable/resizable columns for the FlexTable, because that&#8217;s a rant and a half.  Given that GWT&#8217;s event handling model isn&#8217;t bad, you&#8217;d think they&#8217;d [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> has been out for a while now, and yet there is still basic functionality that is missing from the toolkit.  Don&#8217;t get me started on the lack of draggable/resizable columns for the FlexTable, because that&#8217;s a rant and a half.  Given that GWT&#8217;s event handling model isn&#8217;t bad, you&#8217;d think they&#8217;d have included from the get-go the ability to handle right-clicks and bringing up a <a href="http://en.wikipedia.org/wiki/Context_menu">context menu or popup menu</a>.  Well, even with 1.6 on the doorstep it seems they forgot again or just don&#8217;t care.   Now some people will spout out &#8220;web apps don&#8217;t need or shouldn&#8217;t have right-clicks handled or context menus overridden&#8221;&#8230;&#8230;and for those I say STFU!  Web apps are used for more than just banking, news, forums and dare I say blogs.  The browser is becoming the new medium for running applications and just because an application is running in a browser doesn&#8217;t mean we should limit functionality.  That&#8217;s about as narrow minded as saying that we&#8217;ve only had one mouse button for this long, why add a second one?  Duh!</p>
<p>Anyway, enough with the blabbing.  I&#8217;ve put together a simple example to add a right click context menu and override the default browser context menu using GWT. <br />
<span id="more-370"></span><br />
In the box below you can try it out, right-click in there and you can demo it.</p>
<table>
<tr>
<td><iframe src="http://whatwouldnickdo.com/rightclickex/RightClickEx.html" width="300" frameborder="0" height="310">  &amp;amp;lt;p&amp;amp;gt;Your browser does not support iframes.&amp;amp;lt;/p&amp;amp;gt; </iframe></td>
<td>
</td>
</tr>
</table>
<p>In case the iframe doesn&#8217;t show up in your browser you can see and try the example <a href="http://whatwouldnickdo.com/rightclickex/RightClickEx.html">here</a>.<br />
Now here&#8217;s how it&#8217;s done.</p>
<p>I used a DeckPanel to switch between several panels. The popup context menu is used to choose.  To allow the DeckPanel to catch the right-click event (and you can also listen for double-clicks and several other things) I extended the DeckPanel.   For simplicity I added &#8220;Adv&#8221; (Advanced) in front of the several classes I&#8217;ve extended so this one will be <strong>AdvDeckPanel</strong>.  The first thing to do in the constructor is add <strong>sinkEvents()</strong>. Then we&#8217;ll override <strong>onBrowserEvent()</strong> in the class.  Here&#8217;s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> AdvDeckPanel<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;">super</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  sinkEvents<span style="color: #009900;">&#40;</span><span style="color: #003399;">Event</span>.<span style="color: #006633;">ONMOUSEUP</span> <span style="color: #339933;">|</span> <span style="color: #003399;">Event</span>.<span style="color: #006633;">ONDBLCLICK</span> <span style="color: #339933;">|</span> <span style="color: #003399;">Event</span>.<span style="color: #006633;">ONCONTEXTMENU</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;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onBrowserEvent<span style="color: #009900;">&#40;</span><span style="color: #003399;">Event</span> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  GWT.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;onBrowserEvent&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  event.<span style="color: #006633;">cancelBubble</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//This will stop the event from being propagated</span>
  event.<span style="color: #006633;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>DOM.<span style="color: #006633;">eventGetType</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #003399;">Event</span>.<span style="color: #006633;">ONMOUSEUP</span><span style="color: #339933;">:</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DOM.<span style="color: #006633;">eventGetButton</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #003399;">Event</span>.<span style="color: #006633;">BUTTON_LEFT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        GWT.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Event.BUTTON_LEFT&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        listener.<span style="color: #006633;">onClick</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, event<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>DOM.<span style="color: #006633;">eventGetButton</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #003399;">Event</span>.<span style="color: #006633;">BUTTON_RIGHT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        GWT.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Event.BUTTON_RIGHT&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        listener.<span style="color: #006633;">onRightClick</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #003399;">Event</span>.<span style="color: #006633;">ONDBLCLICK</span><span style="color: #339933;">:</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #003399;">Event</span>.<span style="color: #006633;">ONCONTEXTMENU</span><span style="color: #339933;">:</span>
      GWT.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Event.ONCONTEXTMENU&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Do nothing</span>
  <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end switch</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notice the two lines in onBrowserEvent():<br />
<strong> event.cancelBubble(true);<br />
event.preventDefault();</strong></p>
<p>These are the two lines that tell the browser not to show it&#8217;s default context popup menu.  Also note that overriding the default context menu doesn&#8217;t work in all browsers, I&#8217;m not sure if this is a bug in GWT.  If you&#8217;re using firefox then you&#8217;ll have no problems, with IE you may need to add the following to your html:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body oncontextmenu=&quot;return false;&quot;&gt;</pre></div></div>

<p>Other than that there&#8217;s just a switch statement that checks the event type, in this case we&#8217;re interested with <strong>ONMOUSEUP</strong>, and we&#8217;ll call the listener&#8217;s <strong>onClick() </strong>or <strong>onRightClick()</strong> based on the Event&#8217;s fields.</p>
<p>AdvDeckPanel also has a reference to AdvClickListener which looks like:</p>

<div class="wp_syntax"><div 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;">interface</span> AdvClickListener <span style="color: #000000; font-weight: bold;">extends</span> ClickListener <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span>Widget sender, <span style="color: #003399;">Event</span> event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">void</span> onRightClick<span style="color: #009900;">&#40;</span>Widget sender, <span style="color: #003399;">Event</span> event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This reference is basically the same as ClickListener, but has a separate method to handle the right-click.  I also pass the <strong>Event</strong> object so I can get the x and y from the click so the context menu shows up at that location instead of the top-left of the screen.</p>
<p>AdvDeckPanel implements <strong>AdvClickNotifier</strong> which does the same thing as GWT&#8217;s <strong>SourcesClickEvents</strong> interface, but handles the <strong>AdvClickListener</strong> instead.</p>

<div class="wp_syntax"><div 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;">interface</span> AdvClickNotifier <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addClickListener<span style="color: #009900;">&#40;</span>AdvClickListener listener<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> removeClickListener<span style="color: #009900;">&#40;</span>AdvClickListener listener<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So, once you have your widget (in this case the AdvDeckPanel) and the listeners set up to handle the right-click, then we add in the code to build the popup menu and commands that go with it.  I put all of this in the <strong>EntryPoint</strong>.  I have three widgets (panels) and a <strong>Command</strong> for each like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> AdvDeckPanel deckPanel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AdvDeckPanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">private</span> PopupPanel popupPanel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PopupPanel<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> VerticalPanel defaultPanel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> VerticalPanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> SimplePanel imagePanel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimplePanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> SimplePanel sponserPanel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimplePanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Command showAlertCommand <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Command<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> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    deckPanel.<span style="color: #006633;">showWidget</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    popupPanel.<span style="color: #006633;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Window</span>.<span style="color: #006633;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hope this example helps.&quot;</span><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: #339933;">;</span>
&nbsp;
Command showImageCommand <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Command<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> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    deckPanel.<span style="color: #006633;">showWidget</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    popupPanel.<span style="color: #006633;">hide</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: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
Command showSponserCommand <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Command<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> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    deckPanel.<span style="color: #006633;">showWidget</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    popupPanel.<span style="color: #006633;">hide</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: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A <strong>Command</strong> is called when the <strong>MenuItem</strong> is clicked.</p>
<p>Now the code to build the menu, link the commands, and handle the right-click:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> createPopupMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">MenuBar</span> popupMenuBar <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">MenuBar</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">MenuItem</span> alertItem <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">MenuItem</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Show alert&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span>, showAlertCommand<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">MenuItem</span> imageItem <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">MenuItem</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Show Oliver &quot;</span>, <span style="color: #000066; font-weight: bold;">true</span>, showImageCommand<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">MenuItem</span> sponserItem <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">MenuItem</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Show sponser &quot;</span>, <span style="color: #000066; font-weight: bold;">true</span>, showSponserCommand<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  popupPanel.<span style="color: #006633;">setStyleName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;popup&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  alertItem.<span style="color: #006633;">addStyleName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;popup-item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  imageItem.<span style="color: #006633;">addStyleName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;popup-item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  sponserItem.<span style="color: #006633;">addStyleName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;popup-item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  popupMenuBar.<span style="color: #006633;">addItem</span><span style="color: #009900;">&#40;</span>alertItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  popupMenuBar.<span style="color: #006633;">addItem</span><span style="color: #009900;">&#40;</span>imageItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  popupMenuBar.<span style="color: #006633;">addItem</span><span style="color: #009900;">&#40;</span>sponserItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  popupMenuBar.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  popupPanel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>popupMenuBar<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;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onRightClick<span style="color: #009900;">&#40;</span>Widget sender, <span style="color: #003399;">Event</span> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> DOM.<span style="color: #006633;">eventGetClientX</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">int</span> y <span style="color: #339933;">=</span> DOM.<span style="color: #006633;">eventGetClientY</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  popupPanel.<span style="color: #006633;">setPopupPosition</span><span style="color: #009900;">&#40;</span>x, y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  popupPanel.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Lastly, to make the menu actually look like a popup menu I modified the CSS like so:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.popup</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span> <span style="color: #993333;">gray</span> <span style="color: #993333;">gray</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</span> <span style="color: #933;">3px</span> <span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.popup-item</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">80</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>What this does is makes it so the border isn&#8217;t the thick default GWT blue, and uses a thin border with the right and bottom borders a bit thicker.  This gives the popup that shadowed look.</p>
<p>A couple of books worth checking out are: <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FGWT-Action-Easy-Google-Toolkit%2Fdp%2F1933988231%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1250784594%26sr%3D8-2&#038;tag=homenick-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">GWT in Action</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=ur2&#038;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />and <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FGWT-Practice-Robert-Cooper%2Fdp%2F1933988290%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1250784594%26sr%3D8-1&#038;tag=homenick-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">GWT in Practice</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=ur2&#038;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
<a href="http://whatwouldnickdo.com/wordpress/blog-attachments/right-click-gwt.7z">Here&#8217;s the source</a> and more links.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/gcavltuIZCMQYPrwmHBPwNIoK6c/0/da"><img src="http://feedads.g.doubleclick.net/~a/gcavltuIZCMQYPrwmHBPwNIoK6c/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gcavltuIZCMQYPrwmHBPwNIoK6c/1/da"><img src="http://feedads.g.doubleclick.net/~a/gcavltuIZCMQYPrwmHBPwNIoK6c/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/OtK8RqFkFhY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/</feedburner:origLink></item>
		<item>
		<title>GWT Yellow Fade Technique (YFT)</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/DcTnL5BNMuw/</link>
		<comments>http://whatwouldnickdo.com/wordpress/306/gwt-yellow-fade-technique-yft/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 21:43:21 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web-dev]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=306</guid>
		<description><![CDATA[This is a quick example of a fading technique which notifies that a change or update in your GWT app has happened.&#160; Seems like every ajax site out there uses a technique similar to this to notify the user that something has happened.&#160; As I write this post, Google Docs flashes up a yellow &#8220;Saving&#8230;&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick example of a fading technique which notifies that a change or update in your <a href="http://code.google.com/webtoolkit/">GWT</a> app has happened.<span id="more-306"></span>&nbsp; Seems like every ajax site out there uses a technique similar to this to notify the user that something has happened.&nbsp; As I write this post, Google Docs flashes up a yellow &#8220;Saving&#8230;&#8221; box for a couple of seconds to let me know my document was automatically saved.&nbsp; This &#8220;Saving&#8230;&#8221; flash box functionality is actually something I was about to put into an application, so I did some searches to see what kind of information was out there.&nbsp; I found nothing on doing it in GWT, actually all you&#8217;ll see out there is a bunch of finger pointing and chest bashing about who came up with the technique first (who cares?).&nbsp; I put together a really fast example (which you can see and try below) and a handler that you can plug into your own app to accomplish the same thing.&nbsp;</p>
<p>
<iframe src="http://whatwouldnickdo.com/YFT/YellowFadeTech.html" width="300" frameborder="0" height="270">  &amp;amp;lt;p&amp;amp;gt;Your browser does not support iframes.&amp;amp;lt;/p&amp;amp;gt; </iframe><br />
In case the iframe doesn&#8217;t show up in your browser you can see and try the example <a href="http://whatwouldnickdo.com/YFT/YellowFadeTech.html">here</a>.<br />
<br />
First, let me explain how it&#8217;s all done.&nbsp; Using a list of colors, in this case different shades of yellow, you add and remove styles (a color) of a widget.&nbsp; The colors are stored in the CSS file.&nbsp; The change is triggered by a timer.&nbsp; The <b>YellowFadeHandler</b> class has an inner class called <b>FadeObject</b> which holds a color and a <b>com.google.gwt.user.client.ui.UIObject</b>. This UIObject is the super class of all major GWT widgets and has the methods:</p>
<pre><b>addStyleName</b>(java.lang.String&nbsp;style)
<span style="font-family: Verdana;">and</span>
<b>removeStyleName</b>(java.lang.String&nbsp;style)
</pre>
<p><strong>The FadeObject class</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">class</span> FadeObject <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> UIObject uiObj <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> color <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> FadeObject<span style="color: #009900;">&#40;</span>UIObject uiObj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">uiObj</span> <span style="color: #339933;">=</span> uiObj<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">uiObj</span>.<span style="color: #006633;">addStyleName</span><span style="color: #009900;">&#40;</span>yftStyles<span style="color: #009900;">&#91;</span>color<span style="color: #009900;">&#93;</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;">public</span> <span style="color: #000066; font-weight: bold;">void</span> nextColor<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;">if</span> <span style="color: #009900;">&#40;</span>color <span style="color: #339933;">==</span> transparent_color<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
		uiObj.<span style="color: #006633;">removeStyleName</span><span style="color: #009900;">&#40;</span>yftStyles<span style="color: #009900;">&#91;</span>color<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		color<span style="color: #339933;">++;</span>
		uiObj.<span style="color: #006633;">addStyleName</span><span style="color: #009900;">&#40;</span>yftStyles<span style="color: #009900;">&#91;</span>color<span style="color: #009900;">&#93;</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;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getColor<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> color<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> isTransparent<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;">if</span> <span style="color: #009900;">&#40;</span>color <span style="color: #339933;">==</span> transparent_color<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">// end class FadeObject</span></pre></div></div>

<p>
<strong>The YellowFadeHandler class</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>FadeObject<span style="color: #339933;">&gt;</span> fadeObjectList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LinkedList<span style="color: #339933;">&lt;</span>FadeObject<span style="color: #339933;">&gt;</span><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;">public</span> YellowFadeHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">Timer</span> t <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Timer</span><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> run<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;">if</span> <span style="color: #009900;">&#40;</span>fadeObjectList.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Iterator<span style="color: #339933;">&lt;</span>FadeObject<span style="color: #339933;">&gt;</span> iter <span style="color: #339933;">=</span> fadeObjectList.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> iter.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          FadeObject fObj <span style="color: #339933;">=</span> iter.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          fObj.<span style="color: #006633;">nextColor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fObj.<span style="color: #006633;">isTransparent</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>
            <span style="color: #666666; font-style: italic;">//if it hits the transparent color then fading is done so remove it.</span>
            iter.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            GWT.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;fade object removed&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    t.<span style="color: #006633;">scheduleRepeating</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">120</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;">public</span> <span style="color: #000066; font-weight: bold;">void</span> add<span style="color: #009900;">&#40;</span>UIObject obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>obj <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
    FadeObject fo <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FadeObject<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fadeObjectList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, fo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    GWT.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;fade object added&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>My YellowFadeHandler class holds a List of these FadeObjects.&nbsp; When the timer fires, it iterates through the list and changes (removes the old and adds the new) styles of the widgets.&nbsp; When the style is changed to the last color in the chain (transparent), the widget is then removed from the list.&nbsp; So to have a widget go through the yellow fade, all that needs to be done is call handler.add(widget);<br />
Super simple.  <a href="http://whatwouldnickdo.com/wordpress/blog-attachments/yft-test.7z">Here&#8217;s the source.</a><br />
A couple of books worth checking out are: <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FGWT-Action-Easy-Google-Toolkit%2Fdp%2F1933988231%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1250784594%26sr%3D8-2&#038;tag=homenick-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">GWT in Action</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=ur2&#038;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />and <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FGWT-Practice-Robert-Cooper%2Fdp%2F1933988290%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1250784594%26sr%3D8-1&#038;tag=homenick-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">GWT in Practice</a><img src="http://www.assoc-amazon.com/e/ir?t=homenick-20&#038;l=ur2&#038;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>

<p><a href="http://feedads.g.doubleclick.net/~a/yQAmf5m2FpEKANXM3_a8UbbsQKI/0/da"><img src="http://feedads.g.doubleclick.net/~a/yQAmf5m2FpEKANXM3_a8UbbsQKI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/yQAmf5m2FpEKANXM3_a8UbbsQKI/1/da"><img src="http://feedads.g.doubleclick.net/~a/yQAmf5m2FpEKANXM3_a8UbbsQKI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/DcTnL5BNMuw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/306/gwt-yellow-fade-technique-yft/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/306/gwt-yellow-fade-technique-yft/</feedburner:origLink></item>
		<item>
		<title>Eclipse C/C++ and Linux Libraries</title>
		<link>http://feedproxy.google.com/~r/whatwouldnickdo/~3/5BXR0j_yTUo/</link>
		<comments>http://whatwouldnickdo.com/wordpress/328/eclipse-cdt-and-linux-libraries/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 15:50:39 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=328</guid>
		<description><![CDATA[This is a really quick tutorial on configuring Eclipse CDT (C/C++ Development Tools) so you can work with shared libraries.  A lot of this may be basic for some readers, but for a programmer that&#8217;s used to Visual Studio and a Windows dll environment it may not.  Windows uses DLL (Dynamic link library) with the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a really quick tutorial on configuring <a href="http://www.eclipse.org/cdt/">Eclipse CDT</a> (C/C++ Development Tools) so you can work with <a href="http://en.wikipedia.org/wiki/Shared_library#Shared_libraries">shared libraries</a>.  A lot of this may be basic for some readers, but for a programmer that&#8217;s used to Visual Studio and a Windows dll environment it may not.  <span id="more-328"></span>Windows uses DLL (Dynamic link library) with the .dll extension.  The closest linux equivalent is the shared library which uses a .so extension.   I&#8217;m going to use <a href="http://en.wikipedia.org/wiki/Libavcodec">libavcodec.so</a> as the shared library to be used in my example.  This library is part of the <a href="http://ffmpeg.org/">ffmpeg</a> project.</p>
<p>Assuming you already have Eclipse CDT, the first thing you need to do is create a new project.  After starting Eclipse, click on <strong>File-&gt;New-&gt;C Project</strong> and you&#8217;ll get a dialog box to choose the type of project (executable, static library, shared library, etc).  For this example, I&#8217;m choosing <strong>Executable </strong>and <strong>Hello World ANSI C Project</strong>.  Put in a name and click <strong>Finish</strong>.</p>
<p><a href="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/01-lec-new.png"><img class="size-medium wp-image-331 alignnone" title="01-lec-new" src="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/01-lec-new-300x264.png" alt="01-lec-new" width="300" height="264" /></a></p>
<p>Next you&#8217;ll see you have a new project in the left-side panel with a .c file containing a simple hello world program.</p>
<p><a href="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/02-lec-project.png"><img class="alignnone size-full wp-image-333" title="02-lec-project" src="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/02-lec-project.png" alt="02-lec-project" width="268" height="186" /></a></p>
<p>Now in my example I&#8217;ll add the line <strong>#include &lt;avcodec.h&gt;</strong> to set up my include.  If you need to add an include directory (where your header files are located) then in the Eclipse menu go to <strong>Project-&gt;Properties</strong> then open the <strong>C/C++ Build</strong> branch and click on <strong>Settings</strong>.  On the right side click on the <strong>Directories </strong>branch of <strong>GCC C Compiler</strong>.  You can then add directories to your include path.</p>
<p><a href="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/03-lec-include.png"><img class="alignnone size-medium wp-image-336" title="03-lec-include" src="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/03-lec-include-300x277.png" alt="03-lec-include" width="300" height="277" /></a></p>
<p>In this same dialog you can click on <strong>Libraries </strong>in the <strong>GCC C Linker</strong> branch to add any libraries to the project for linking.  The library I&#8217;m adding is the <strong>libavcodec.so</strong> shared library.  To add this (notice in the screenshot) I only need to add <strong>avcodec</strong>, without the prefix <strong>lib</strong> and <strong>.so</strong> extension.  This might be new to Windows programmers.  Since you&#8217;re adding a library it&#8217;s assumed to have the lib and .so in the name.</p>
<p><a href="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/04-lec-libs.png"><img class="alignnone size-medium wp-image-337" title="04-lec-libs" src="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/04-lec-libs-300x207.png" alt="04-lec-libs" width="300" height="207" /></a></p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=homenick-20&#038;o=1&#038;p=13&#038;l=st1&#038;mode=books&#038;search=programming%20linux&#038;fc1=B85B5A&#038;lt1=_blank&#038;lc1=3366FF&#038;bg1=FAFAFA&#038;f=ifr" marginwidth="0" marginheight="0" width="468" height="60" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe></p>
<p>Now let&#8217;s just add a couple of lines to the main() so we can test a compile with the libavcodec library.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;avcodec.h&gt;</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   avcodec_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   avcodec_register_all<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And then to run it, in the menu toolbar click on the run arrow and choose <strong>Run As-&gt;C/C++ Local Application</strong>.<br />
<a href="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/05-lec-run.png"><img class="alignnone size-medium wp-image-338" title="05-lec-run" src="http://whatwouldnickdo.com/wordpress/wp-content/uploads/2009/02/05-lec-run-300x108.png" alt="05-lec-run" width="300" height="108" /></a><br />
Getting no errors means success.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Ola7_FCcoXIKlPepoYJ0opCMTz8/0/da"><img src="http://feedads.g.doubleclick.net/~a/Ola7_FCcoXIKlPepoYJ0opCMTz8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Ola7_FCcoXIKlPepoYJ0opCMTz8/1/da"><img src="http://feedads.g.doubleclick.net/~a/Ola7_FCcoXIKlPepoYJ0opCMTz8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/whatwouldnickdo/~4/5BXR0j_yTUo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://whatwouldnickdo.com/wordpress/328/eclipse-cdt-and-linux-libraries/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://whatwouldnickdo.com/wordpress/328/eclipse-cdt-and-linux-libraries/</feedburner:origLink></item>
	</channel>
</rss>
