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

<channel>
	<title>digitaldogbyte.com</title>
	<atom:link href="http://www.digitaldogbyte.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digitaldogbyte.com</link>
	<description>powered by kilobits n' bytes</description>
	<lastBuildDate>Sat, 16 Jul 2011 03:01:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>PhoneGap-webOS newCard API tricks</title>
		<link>http://www.digitaldogbyte.com/2011/07/15/phonegap-webos-newcard-api-tricks/</link>
		<comments>http://www.digitaldogbyte.com/2011/07/15/phonegap-webos-newcard-api-tricks/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 03:00:45 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=261</guid>
		<description><![CDATA[Here are few neat tricks that you can use when messing around with PhoneGap-webOS&#8217;s newCard API: have the new card close the parent card close the new card pass data to a the new card NOTE: passing data to a new card was a trick discovered by Ken Schreihofer, he has a blog post that [...]]]></description>
			<content:encoded><![CDATA[<p>Here are few neat tricks that you can use when messing around with PhoneGap-webOS&#8217;s newCard API:</p>
<ul>
<li>have the new card close the parent card</li>
<li>close the new card</li>
<li>pass data to a the new card</li>
</ul>
<p>NOTE: passing data to a new card was a trick discovered by <a href="https://twitter.com/#!/digitalelph" target="_blank">Ken Schreihofer</a>, he has a <a href="http://weboscapades.blogspot.com/2011/07/passing-parameters-to-new-card-in.html" target="_blank">blog post that explains it in detail</a>.</p>
<p>I&#8217;ve included his example along with the examples for closing parent card &#038; new card in this example PhoneGap-webOS 1.0.0rc1 app.</p>
<p>In the index.html of the example app, you will need to open up a new card &#8211; which will use &#8220;child.html&#8221; as the source of the new card in this example.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;PhoneGap WebOS&lt;/title&gt;	
	&lt;script type=&quot;text/javascript&quot; src=&quot;phonegap-1.0.0.js&quot;&gt;&lt;/script&gt;   	
&lt;/head&gt;
&lt;body&gt;
&lt;button onclick=&quot;navigator.window.newCard('child.html?firstName=herm&amp;lastName=wong');&quot;&gt;create new card &amp; pass data to it&lt;/button&gt;
&lt;script&gt;                         
document.addEventListener('deviceready', function () {
    // PhoneGap is ready, do all your stuf here
}, false);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Next create the child.html file in the same directory as your index.html file. Make sure that the source matches the code below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&nbsp;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;Child Window&lt;/title&gt;
&nbsp;
	&lt;!--
&nbsp;
	the data passing example is credited to: Ken Schreihofer   
	http://weboscapades.blogspot.com/2011/07/passing-parameters-to-new-card-in.html
&nbsp;
	--&gt;
&nbsp;
	&lt;script type=&quot;text/javascript&quot;&gt;
	    var query = location.href.substring((location.href.indexOf('?')+1), location.href.length);
	    if(location.href.indexOf('?') &lt; 0) query = '';
	    querysplit = query.split('&amp;');
	    query = new Array();
&nbsp;
	    for(var i = 0; i &lt; querysplit.length; i++){
	        var namevalue = querysplit[i].split('=');
	        namevalue[1] = namevalue[1].replace(/\+/g, ' ');
	        query[namevalue[0]] = unescape(namevalue[1]);
	    }
&nbsp;
	    window.onload = function(){
	        document.getElementById('firstname').innerHTML = query['firstName'];
	    document.getElementById('lastname').innerHTML = query['lastName'];
	    }
	&lt;/script&gt;		
&lt;/head&gt;
&lt;body&gt;
	&lt;h1&gt;Who are you?&lt;/h1&gt;
	&lt;p&gt;Your name is &lt;span id=&quot;firstname&quot;&gt;&lt;/span&gt; &lt;span id=&quot;lastname&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&nbsp;
	&lt;p&gt;&lt;button onClick=&quot;window.opener.close();&quot;&gt;close the parent card&lt;/button&gt;&lt;/p&gt;
&nbsp;
	&lt;p&gt;&lt;button onClick=&quot;window.close();&quot;&gt;close current card&lt;/button&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Run the make script and you should be able to try out these tricks to the newCard API.</p>
<p>Example app &#038; source can be downloaded <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-newcard-tricks/phonegap-webos_100rc1_newcard_tricks.zip" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/07/15/phonegap-webos-newcard-api-tricks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PhoneGap-webOS 1.0.0rc1 now with Touch Events</title>
		<link>http://www.digitaldogbyte.com/2011/07/12/phonegap-webos-1-0-0rc1-now-with-touch-events-2/</link>
		<comments>http://www.digitaldogbyte.com/2011/07/12/phonegap-webos-1-0-0rc1-now-with-touch-events-2/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 05:37:21 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=256</guid>
		<description><![CDATA[The release of PhoneGap-webOS 1.0.0rc1 adds built-in support for touch events. The touch events use the thumbs.js library which has been rolled into PhoneGap-webOS. To use the touch events in PhoneGap-webOS add the following lines of code to your HTML file. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [...]]]></description>
			<content:encoded><![CDATA[<p>The release of PhoneGap-webOS 1.0.0rc1 adds built-in support for touch events. The touch events use the <a href="http://mwbrooks.github.com/thumbs.js/" target="_blank">thumbs.js library</a> which has been rolled into PhoneGap-webOS.</p>
<p>To use the touch events in PhoneGap-webOS add the following lines of code to your HTML file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
    &lt;head&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
&nbsp;
        &lt;button id=&quot;btnTouchStart&quot;&gt;Touch Start&lt;/button&gt;
&nbsp;
        &lt;script&gt;                         
             document.addEventListener('deviceready', function () {
                  // PhoneGap is ready, do all your stuf here
             }, false);
&nbsp;
            document.querySelector('#btnTouchStart').addEventListener('touchstart', onTouchEvent, false);
&nbsp;
            function onTouchEvent(event) {
	         navigator.notification.alert(event.type);
            }
        &lt;/script&gt; 
&nbsp;
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>This will create a button and attach an event listener for a &#8216;touchstart&#8217; event being triggered from the button. The onTouchEvent method will simple display a notification with the event type being handled.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-touchevents/touchstart_notification.png" alt="PhoneGap webOS touchstart event example"/></p>
<p>Full source code with examples of all touch &#038; mouse events can be found <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-touchevents/phonegap-webos-touchevents.zip" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/07/12/phonegap-webos-1-0-0rc1-now-with-touch-events-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with PhoneGap-webOS 0.9.6</title>
		<link>http://www.digitaldogbyte.com/2011/07/04/getting-started-with-phonegap-webos-0-9-6/</link>
		<comments>http://www.digitaldogbyte.com/2011/07/04/getting-started-with-phonegap-webos-0-9-6/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 17:32:15 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=225</guid>
		<description><![CDATA[With the release of PhoneGap 0.9.6 last week (week of June 27, 2011), there was some minor code clean up done to the way PhoneGap-webOS initializes. This blog post will quickly run through an example of how to set up a simple &#8220;Hello World&#8221; example using PhoneGap-webOS 0.9.6. If you would like to see an [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of PhoneGap 0.9.6 last week (week of June 27, 2011), there was some minor code clean up done to the way PhoneGap-webOS initializes.</p>
<p>This blog post will quickly run through an example of how to set up a simple &#8220;Hello World&#8221; example using PhoneGap-webOS 0.9.6.</p>
<p>If you would like to see an example app that demonstrates the various PhoneGap-webOS API calls &amp; features you can refer to the <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-helloworld/phonegap-webos-helloworld.zip" target="_blank">example app</a> that was made available in my <a href="http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/" target="_blank">Getting Started with PhoneGap-webOS 0.9.5 tutorial</a>.</p>
<p>The first couple steps are to make sure you have all the tools and to set up your project.</p>
<ol>
<li>The list of necessary software &#038; tools listed in step 3 on the <a href="http://www.phonegap.com/start#webos" target="_blank">PhoneGap webOS</a> page.</li>
<li>Set up your project by following step 4 on the PhoneGap webOS page, be sure to leave your terminal/cygwin window open as you will need it later.</li>
</ol>
<p>From here you can delete or rename the index.html file (if you want to keep it as a reference) in the framework folder, we will be working on creating an app from the beginning.</p>
<ol>
<li>Create a new index.html file in the framework folder.</li>
<li>Include the phonegap.js library in the &lt;head&gt; of your index.html</li>
<li>Add the text &#8220;Hello World&#8221; within the &lt;body&gt; tags</li>
<li>Add an event listener for the &#8216;deviceready&#8217; event to the document &#8211; see the code sample below</li>
</ol>
<p>The source of your index.html should look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
    &lt;head&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        Hello World
&nbsp;
        &lt;script&gt;                         
             document.addEventListener('deviceready', function () {
                  // PhoneGap is ready, do all your stuf here
             }, false);
        &lt;/script&gt; 
&nbsp;
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>To view your work, you&#8217;ll want to either:</p>
<ul>
<li>open the Palm emulator</li>
<li>set your Palm device to developer mode and plug it in</li>
</ul>
<p>Go back to terminal/cygwin and type &#8220;make&#8221; (without the quotes).</p>
<p>You should see your hello world example app in the emulator or device.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-helloworld/phonegap-webos-helloworld.png" alt="PhoneGap webOS Hello World Example" /></p>
<p>Source can be found <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-helloworld/phonegap_webos_096_helloworld.zip" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/07/04/getting-started-with-phonegap-webos-0-9-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PhoneGap-0.9.5 webOS newCard API</title>
		<link>http://www.digitaldogbyte.com/2011/05/13/phonegap-0-9-5-webos-newcard-api/</link>
		<comments>http://www.digitaldogbyte.com/2011/05/13/phonegap-0-9-5-webos-newcard-api/#comments</comments>
		<pubDate>Fri, 13 May 2011 18:32:42 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=212</guid>
		<description><![CDATA[WebOS uses the concept of cards as it&#8217;s main UI element. Each application exists in a card, applications can even open up multiple cards. For example, if you had the Map app and Browser active on your webOS device, both apps would exist in their own instance of a card. Cards on the webOS interface. [...]]]></description>
			<content:encoded><![CDATA[<p>WebOS uses the concept of cards as it&#8217;s main UI element. Each application exists in a card, applications can even open up multiple cards. For example, if you had the Map app and Browser active on your webOS device, both apps would exist in their own instance of a card.</p>
<p>Cards on the webOS interface.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-newcard/phonegap-webos-newcard.png" alt="Cards on the webOS interface" /></p>
<p>To open a new card in PhoneGap-0.9.5 webOS you will need to call the newCard API.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">navigator.window.newCard(url, html);</pre></td></tr></table></div>

<p>The newCard method takes the following parameters:</p>
<ul>
<li>url &#8211; url that should be loaded into the new card</li>
<li>html (optional) &#8211; html string that the new card should render</li>
</ul>
<p>The following example will demonstrate a few different ways to create new cards in PhoneGap webOS. If you&#8217;ve never worked with PhoneGap-0.9.5 WebOS; I would strongly recommend that you follow through my <a href="http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/">Getting Started with PhoneGap-0.9.5 WebOS</a> tutorial.</p>
<p>The following example shows how to:</p>
<ol>
<li>load a local html file into a new card</li>
<li>load an external url into a new card</li>
<li>load inline html into a new card</li>
</ol>
<p>Set up a new PhoneGap webOS project and modify the index.html so that it matches the code sample provided below.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;PhoneGap WebOS&lt;/title&gt;
&nbsp;
	&lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;   
	&lt;script type=&quot;text/javascript&quot;&gt;
 		function onLoad() {
	    	navigator.device.deviceReady();
		}
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;onLoad();&quot;&gt;                                           
	&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;new card with local source&quot; onclick=&quot;navigator.window.newCard('newcard.html');&quot;&gt;&lt;/p&gt;                                                                       
	&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;new card with online source&quot; onclick=&quot;navigator.window.newCard('http://www.phonegap.com');&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;new card with inline html&quot; onclick=&quot;navigator.window.newCard('', '&lt;html&gt;&lt;body&gt;Hello again!&lt;/body&gt;&lt;/html&gt;');&quot;&gt;&lt;/p&gt;    
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Next create a new html file called newcard.html in the same directory as your index.html. Update the source of the newcard.html file so that it matches the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;New Card Example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
New Card content goes here.
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>The source for the example can be downloaded <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-newcard/phonegap-webos-newcard.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/05/13/phonegap-0-9-5-webos-newcard-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SQLite with PhoneGap-0.9.5 webOS</title>
		<link>http://www.digitaldogbyte.com/2011/05/12/using-sqlite-with-phonegap-0-9-5-webos/</link>
		<comments>http://www.digitaldogbyte.com/2011/05/12/using-sqlite-with-phonegap-0-9-5-webos/#comments</comments>
		<pubDate>Thu, 12 May 2011 22:33:23 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=191</guid>
		<description><![CDATA[PhoneGap-0.9.5 webOS no longer includes the Mojo framework, so you will not be able to use the Depot APIs to create &#038; manipulate local storage. If your webOS app needs a database, you will need to use HTML5&#8242;s storage functionality. If you&#8217;re already familiar with HTML5 storage and just want to reference the storage APIs [...]]]></description>
			<content:encoded><![CDATA[<p>PhoneGap-0.9.5 webOS no longer includes the Mojo framework, so you will not be able to use the Depot APIs to create &#038; manipulate local storage. If your webOS app needs a database, you will need to use HTML5&#8242;s storage functionality.</p>
<p>If you&#8217;re already familiar with HTML5 storage and just want to reference the storage APIs supported in PhoneGap, you can take a look at the <a href="http://docs.phonegap.com/phonegap_storage_storage.md.html#Storage" target="_blank">PhoneGap Storage API docs</a>.</p>
<p>This post will provide a step by step walkthrough on how to:</p>
<ul>
<li>set up an HTML5 SQLite database</li>
<li>insert data into the database</li>
<li>retrieve data from the database</li>
</ul>
<p>First step is to set up your PhoneGap webOS project by following these <a href="http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/" target="_blank">steps</a>.</p>
<p><strong>Create / Open a database connection</strong></p>
<p>To create a new database or to open a connection to an existing database you need to use the window.openDatabase method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">var db = window.openDatabase(name, version, displayName, size);</pre></td></tr></table></div>

<p>The parameters used by the openDatabase method:</p>
<ul>
<li>name &#8211; name of the database instance</li>
<li>version (optional) &#8211; version of the database</li>
<li>displayName (optional) &#8211; database&#8217;s display name</li>
<li>size (optional) &#8211; size of the database in bytes</li>
</ul>
<p>Modify your index.html file&#8217;s source so that it looks like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;PhoneGap WebOS&lt;/title&gt;
&nbsp;
	&lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;   
	&lt;script type=&quot;text/javascript&quot;&gt;
                var db; 		
 		function onLoad() {
	    	     navigator.device.deviceReady();
		} 
&nbsp;
		// create the db instance
		function createDB() {  
			// creates or opens a new db connection
			db = window.openDatabase(&quot;test&quot;, &quot;1.0&quot;, &quot;Test DB&quot;);
		}		
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;onLoad();&quot;&gt;
	&lt;input type=&quot;button&quot; onclick=&quot;createDB();&quot; value=&quot;Test SQLite DB&quot;&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>When &#8220;Test SQLite DB&#8221; button is pressed it will create a database named &#8220;test&#8221; (or open a connection to the &#8220;test&#8221; database if it already exists) by calling the createDB() method which in turn calls the window.openDatabase method. The app will appear to do nothing if you run it and press the button since we have not added any notifications to indicate the result of the database creation.</p>
<p>In the next section, we will insert some test data into the database and display a notification that will indication if the database creation &#038; data insertion was successful.</p>
<p><strong>Inserting data into the database</strong></p>
<p>To perform any CRUD (Create/Read/Update/Delete) operaton on the database you will need to use the database&#8217;s transaction method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">db.transaction(methodName, errorCallback, successCallback);</pre></td></tr></table></div>

<p>The transaction method accepts the following parameters:</p>
<ul>
<li>methodName &#8211; name of the method that contains the SQL statements you want to execute</li>
<li>errorCallback (optional) &#8211; name of the method that gets called if an error occurs when executing the instructions in methodName</li>
<li>successCallback (optional) &#8211; name of the method that gets called when the instructions in methodName are executed successfully</li>
</ul>
<p>The transaction object which gets passed into the methodName method as a parameter has an executeSql method which is used to execute SQL statements. In our example below, our methodName is the populateDB method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">tx.executeSql(sqlStatement, argumentArray, successCallback, errorCallback);</pre></td></tr></table></div>

<p>The executeSql method accepts the following parameters:</p>
<ul>
<li>sqlStatement &#8211; SQL statement that needs to be performed on the database</li>
<li>argumentArray (optional) &#8211; values that can be mapped to SQL arguments represented by &#8216;?&#8217; in the sqlStatement</li>
<li>successCallback (optional) &#8211; method to be called if the executeSql method successfully executes</li>
<li>errorCallback (optional) &#8211; method to be called if the executeSql method isn&#8217;t successful</li>
</ul>
<p>Update your index.html so that the source matches the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;PhoneGap WebOS&lt;/title&gt;
&nbsp;
	&lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;   
	&lt;script type=&quot;text/javascript&quot;&gt; 		
 		function onLoad() {
	    	navigator.device.deviceReady();
		} 
&nbsp;
		// create the db instance
		function createDB() {  
			// creates or opens a new db connection
			var db = window.openDatabase(&quot;test&quot;, &quot;1.0&quot;, &quot;Test DB&quot;);
			// call populateDB
			db.transaction(populateDB, errorCB, successCB);			
		}
&nbsp;
		// inserts test data into db
		function populateDB(tx) {
			// drop the DEMO table if it exists
			tx.executeSql('DROP TABLE IF EXISTS DEMO');  
			// create DEMO table with columns id and data
			tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
			// insert test data into DEMO table
			tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, &quot;First row&quot;)');
			tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, &quot;Second row&quot;)');
		} 
&nbsp;
		// generic error handler
		function errorCB(tx, err) {
			navigator.notification.alert(&quot;error: &quot; + err);
		}
&nbsp;
		// success handler for db creation &amp; population
		function successCB() {
			navigator.notification.alert('successfully created &amp; populated');  
		}		   			
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;onLoad();&quot;&gt;
	&lt;input type=&quot;button&quot; onclick=&quot;createDB();&quot; value=&quot;Test SQLite DB&quot;&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>If you run your app now &#038; press on the &#8220;Test SQLite DB&#8221; button, you will get an alert that indicates that the database was successfully created and that data was successfully inserted into your database.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-storage/phonegap-webos-storage-db-create-populate-success.png" alt="Database creation &#038; insertion success" /></p>
<p>Now that we&#8217;re able to insert data into the database, we&#8217;ll want to be able to retrieve the data from the database.</p>
<p><strong>Retrieving data from the database</strong></p>
<p>These last updates will add a method to retrieve all of the test data we have entered into the database. There will be notifications that display the total number of rows added to the database and the contents of each row.</p>
<p>We will be adding a method called &#8216;queryDB&#8217; that will retrieve all of the data from the database and a method named &#8216;querySuccess&#8217; which will display the notifications when if the data retrieval is successful.</p>
<p>Update your index.html so that the source matches the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;PhoneGap WebOS&lt;/title&gt;
&nbsp;
	&lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;   
	&lt;script type=&quot;text/javascript&quot;&gt; 		
 		function onLoad() {
	    	navigator.device.deviceReady();
		} 
&nbsp;
		// create the db instance
		function createDB() {  
			// creates or opens a new db connection
			var db = window.openDatabase(&quot;test&quot;, &quot;1.0&quot;, &quot;Test DB&quot;);
			// call populateDB
			db.transaction(populateDB, errorCB, successCB);			
		}
&nbsp;
		// inserts test data into db
		function populateDB(tx) {
			// drop the DEMO table if it exists
			tx.executeSql('DROP TABLE IF EXISTS DEMO');  
			// create DEMO table with columns id and data
			tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
			// insert test data into DEMO table
			tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, &quot;First row&quot;)');
			tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, &quot;Second row&quot;)');
		} 
&nbsp;
		// generic error handler
		function errorCB(tx, err) {
			navigator.notification.alert(&quot;error: &quot; + err);
		}
&nbsp;
		// success handler for db creation &amp; population
		function successCB() {
			navigator.notification.alert('successfully created &amp; populated'); 
			// call queryDB
			db.transaction(queryDB, errorCB); 
		}
&nbsp;
		// query db for all values in the DEMO table
		function queryDB(tx) {
			tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
		}
&nbsp;
		// display results of a success db query
		function querySuccess(tx, results) {     
			var len = results.rows.length;
			// display alert with number of rows inserted into the db
			navigator.notification.alert('rows inserted: ' + len);
&nbsp;
			// display each item in the recordset in its own alert
			if (len &gt; 0) {
				for (var i=0;i&lt;len;i++) {
					navigator.notification.alert('id: ' + results.rows.item(i).id + ' data: ' + results.rows.item(i).data);
				}
			}
		}		   			
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;onLoad();&quot;&gt;
	&lt;input type=&quot;button&quot; onclick=&quot;createDB();&quot; value=&quot;Test SQLite DB&quot;&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>The source code for this demo can be found <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-storage/phonegap-webos-storage.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/05/12/using-sqlite-with-phonegap-0-9-5-webos/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Notifications &amp; Dashboard in PhoneGap-0.9.5 WebOS</title>
		<link>http://www.digitaldogbyte.com/2011/05/11/notifications-dashboard-in-phonegap-0-9-5-webos/</link>
		<comments>http://www.digitaldogbyte.com/2011/05/11/notifications-dashboard-in-phonegap-0-9-5-webos/#comments</comments>
		<pubDate>Wed, 11 May 2011 22:10:39 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=167</guid>
		<description><![CDATA[If you&#8217;ve never worked with PhoneGap-0.9.5 WebOS; I would strongly recommend that you follow through my Getting Started with PhoneGap-0.9.5 WebOS tutorial. This demonstration applies to the recently released PhoneGap-0.9.5 implementation of WebOS. In this post, I&#8217;ll demonstrate how to use PhoneGap WebOS&#8217; APIs for notifications and dashboard. Notifications PhoneGap WebOS uses an alert or [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve never worked with PhoneGap-0.9.5 WebOS; I would strongly recommend that you follow through my <a href="http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/">Getting Started with PhoneGap-0.9.5 WebOS</a> tutorial.</p>
<p>This demonstration applies to the recently released PhoneGap-0.9.5 implementation of WebOS.</p>
<p>In this post, I&#8217;ll demonstrate how to use PhoneGap WebOS&#8217; APIs for notifications and dashboard.</p>
<p><strong>Notifications</strong></p>
<p>PhoneGap WebOS uses an alert or a banner for notifications:</p>
<ul>
<li>alerts &#8211; alerts can be called with the following method:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">navigator.notification.alert('this is an alert');</pre></td></tr></table></div>

</li>
<li>banners &#8211; banners can be called with the following method:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">navigator.notification.showBanner('this is a banner');</pre></td></tr></table></div>

</li>
</ul>
<p>The alert is an API that wraps the showBanner method so the effect of calling either type of notification will have the same result on the app&#8217;s interface.</p>
<p>When calling the alert or showBanner API, you&#8217;ll see the following result:</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-notification/phonegap-webos-showbanner.png" alt="Alert / Banner example" /></p>
<p><strong>Dashboard</strong></p>
<p>Here are the 2 ways that the dashboard can be invoked from PhoneGap-WebOS:</p>
<ul>
<li>dashboard with local content -

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">navigator.notification.newDashboard('dashboard.html');</pre></td></tr></table></div>

</li>
<li>dashboard with online content -

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">navigator.notification.newDashboard('http://www.phonegap.com','dashboard.html');</pre></td></tr></table></div>

</li>
</ul>
<p>The dashboard.html file is a simple html file where you place your dashboard content.</p>
<p>When calling the dashboard, you&#8217;ll see the dashboard icon along the bottom of the app.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-notification/phonegap-webos-dashboard-icon.png" alt="Dashboard icon" /></p>
<p>Once the dashboard icon has been pressed, the app will display the dashboard content.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-notification/phonegap-webos-dashboard-content.png" alt="Dashboard icon" /></p>
<p><strong>Sample App</strong></p>
<p>Create a PhoneGap-WebOS app using the following source in your index.html file. This sample app will demonstrate how to use the alert &#038; showBanner notifications and the dashboard.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;PhoneGap WebOS&lt;/title&gt;
&nbsp;
	&lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;   
	&lt;script type=&quot;text/javascript&quot;&gt;
 		function onLoad() {
	    	navigator.device.deviceReady();
		}
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;onLoad();&quot;&gt;
	&lt;p&gt;Notification examples&lt;/p&gt;                                                                                     
	&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;show alert&quot; onclick=&quot;navigator.notification.alert('this is an alert');&quot;&gt;&lt;/p&gt; 
	&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;show banner&quot; onclick=&quot;navigator.notification.showBanner('this is a banner');&quot;&gt;&lt;/p&gt;	
&nbsp;
	&lt;p&gt;Dashboard examples&lt;/p&gt;
	&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;dashboard with local content&quot; onclick=&quot;navigator.notification.newDashboard('dashboard.html');&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;dashboard with online content&quot; onclick=&quot;navigator.notification.newDashboard('http://www.phonegap.com', 'dashboard.html');&quot;&gt;&lt;/p&gt; 
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Source for the sample app can be downloaded <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-notification/phonegap-webos-notification.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/05/11/notifications-dashboard-in-phonegap-0-9-5-webos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>setOrientation &amp; setFullScreen in PhoneGap-0.9.5 WebOS</title>
		<link>http://www.digitaldogbyte.com/2011/05/10/setorientation-setfullscreen-in-phonegap-0-9-5-webos/</link>
		<comments>http://www.digitaldogbyte.com/2011/05/10/setorientation-setfullscreen-in-phonegap-0-9-5-webos/#comments</comments>
		<pubDate>Tue, 10 May 2011 23:11:56 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=158</guid>
		<description><![CDATA[If you&#8217;ve never worked with PhoneGap WebOS; I would strongly recommend that you follow through my previous post. This demonstration applies to the recently released PhoneGap-0.9.5 implementation of WebOS. In this post, I&#8217;ll demonstrate how to PhoneGap WebOS&#8217; APIs for screen orientation and window sizing. Setting the screen orientation: To set the screen orientation of [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve never worked with PhoneGap WebOS; I would strongly recommend that you follow through my <a href="http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/">previous post</a>.</p>
<p>This demonstration applies to the recently released PhoneGap-0.9.5 implementation of WebOS.</p>
<p>In this post, I&#8217;ll demonstrate how to PhoneGap WebOS&#8217; APIs for screen orientation and window sizing.</p>
<p>Setting the screen orientation:</p>
<p>To set the screen orientation of your WebOS app you will need to call the navigator.orientation.setOrientation(orientation) method.</p>
<p>The setOrientation method will accept the follow 5 values as valid orientations:</p>
<ul>
<li>up</li>
<li>down</li>
<li>left</li>
<li>right</li>
<li>free</li>
</ul>
<p>To set your app to use the device&#8217;s full screen size you need to call the navigator.window.setFullScreen(boolean) method, which takes a true or false parameter.</p>
<p>If you use the following code in the index.html file of your app, you will be able see how the setOrientation and setFullScreen methods work.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;   
	&lt;script type=&quot;text/javascript&quot;&gt;
 		function onLoad() {
	    	     navigator.device.deviceReady();
		}
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;onLoad();&quot;&gt;
	&lt;input type=&quot;radio&quot; onchange=&quot;navigator.orientation.setOrientation(this.value);&quot; value=&quot;up&quot; name=&quot;orientation&quot; checked&gt;up
	&lt;input type=&quot;radio&quot; onchange=&quot;navigator.orientation.setOrientation(this.value);&quot; value=&quot;down&quot; name=&quot;orientation&quot;&gt;down
	&lt;input type=&quot;radio&quot; onchange=&quot;navigator.orientation.setOrientation(this.value);&quot; value=&quot;left&quot; name=&quot;orientation&quot;&gt;left
	&lt;input type=&quot;radio&quot; onchange=&quot;navigator.orientation.setOrientation(this.value);&quot; value=&quot;right&quot; name=&quot;orientation&quot;&gt;right
	&lt;input type=&quot;radio&quot; onchange=&quot;navigator.orientation.setOrientation(this.value);&quot; value=&quot;free&quot; name=&quot;orientation&quot;&gt;free 
&nbsp;
        &lt;p&gt;&lt;input type=&quot;checkbox&quot; onchange=&quot;navigator.window.setFullScreen(this.checked);&quot;&gt;toggle full screen&lt;/p&gt;      
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Screen capture of the example app with the &#8220;left&#8221; orientation selected.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-setorientation/phonegap-webos-orientation-left.png" alt="Left orientation selected" /></p>
<p>Source for the above example can be found <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-orientation/phonegap-webos-setorientation-setfullscreen.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/05/10/setorientation-setfullscreen-in-phonegap-0-9-5-webos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with PhoneGap WebOS 0.9.5</title>
		<link>http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/</link>
		<comments>http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/#comments</comments>
		<pubDate>Tue, 10 May 2011 19:49:53 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[webOS]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=144</guid>
		<description><![CDATA[This is a walkthrough of creating a webOS mobile app using PhoneGap 0.9.5. If you&#8217;ve previously created webOS apps using older versions of PhoneGap; you will notice that the biggest difference with PhoneGap 0.9.5 is that the Mojo framework is no longer required to author webOS apps. The first couple steps are to make sure [...]]]></description>
			<content:encoded><![CDATA[<p>This is a walkthrough of creating a webOS mobile app using PhoneGap 0.9.5. If you&#8217;ve previously created webOS apps using older versions of PhoneGap; you will notice that the biggest difference with PhoneGap 0.9.5 is that the Mojo framework is no longer required to author webOS apps.</p>
<p>The first couple steps are to make sure you have all the tools and to set up your project.</p>
<ol>
<li>The list of necessary software &#038; tools listed in step 3 on the <a href="http://www.phonegap.com/start#webos" target="_blank">PhoneGap webOS</a> page.</li>
<li>Set up your project by following step 4 on the PhoneGap webOS page, be sure to leave your terminal/cygwin window open as you will need it later.</li>
</ol>
<p>From here you can delete or rename the index.html file (if you want to keep it as a reference) in the framework folder, we will be working on creating an app from the beginning.</p>
<ol>
<li>Create a new index.html file in the framework folder.</li>
<li>Include the phonegap.js library in the <head> of your index.html</li>
<li>Add an onLoad method which triggers the navigator.device.deviceReady() method in the <head> right after the reference to phonegap.js</li>
<li>In the <body> tag&#8217;s onload event call the onLoad() method</li>
<li>Add the text &#8220;Hello World&#8221; within the <body> tags</li>
</ol>
<p>The source of your index.html should look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
    &lt;head&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;phonegap.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot;&gt;
            function onLoad() {
                navigator.device.deviceReady();
            }
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body onload=&quot;onLoad();&quot;&gt;
        Hello World
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>To view your work, you&#8217;ll want to either:</p>
<ul>
<li>open the Palm emulator</li>
<li>set your Palm device to developer mode and plug it in</li>
</ul>
<p>Go back to terminal/cygwin and type &#8220;make&#8221; (without the quotes).</p>
<p>Presto! You should see your hello world example app in the emulator or device.</p>
<p><img src="http://www.digitaldogbyte.com/images/pg-webos-helloworld/phonegap-webos-helloworld.png" alt="PhoneGap webOS Hello World Example" /></p>
<p>Source can be found <a href="http://www.digitaldogbyte.com/downloads/phonegap-webos-helloworld/phonegap-webos-helloworld.zip" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2011/05/10/getting-started-with-phonegap-webos-0-9-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Robotlegs using a shared eventdispatcher between multiple contexts</title>
		<link>http://www.digitaldogbyte.com/2010/08/29/robotlegs-using-a-shared-eventdispatcher-between-multiple-contexts/</link>
		<comments>http://www.digitaldogbyte.com/2010/08/29/robotlegs-using-a-shared-eventdispatcher-between-multiple-contexts/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 02:17:47 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[robotlegs]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=133</guid>
		<description><![CDATA[My last couple posts discussed two different methods of writing modular applications using the Robotlegs framework. This post will demonstrate yet another method of writing modular applications in Robotlegs using a shared eventDispatcher between the modules. This approach requires the creation of a getter method for the eventDispatcher from the Application Shell&#8217;s context. The eventDispatcher [...]]]></description>
			<content:encoded><![CDATA[<p>My last couple posts discussed two different methods of writing modular applications using the Robotlegs framework. This post will demonstrate yet another method of writing modular applications in Robotlegs using a shared eventDispatcher between the modules.</p>
<p>This approach requires the creation of a getter method for the eventDispatcher from the Application Shell&#8217;s context. The eventDispatcher is then injected into the contexts of each module using:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// injects the application shell's eventDispatcher into the module's context</span>
injector<span style="color: #000066; font-weight: bold;">.</span>mapValue<span style="color: #000000;">&#40;</span><span style="color: #004993;">EventDispatcher</span><span style="color: #000066; font-weight: bold;">,</span> Application<span style="color: #000066; font-weight: bold;">.</span>application<span style="color: #000066; font-weight: bold;">.</span>applicationEventDispatcher<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;ApplicationEventDispatcher&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>The &#8220;ApplicationEventDispatcher&#8221; is then used to listen to events and to dispatch events throughout the entire application.</p>
<p>Here is the <a href="http://www.digitaldogbyte.com/downloads/rl_shared_eventdispatcher/RL_Modular_Multiple_Contexts_Shared_Eventdispatcher.html" target="_blank">demo</a> and the <a href="http://www.digitaldogbyte.com/downloads/rl_shared_eventdispatcher/srcview/index.html" target="_blank">source</a> code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2010/08/29/robotlegs-using-a-shared-eventdispatcher-between-multiple-contexts/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Robotlegs modular application with multiple contexts</title>
		<link>http://www.digitaldogbyte.com/2010/08/20/robotlegs-modular-application-with-multiple-contexts/</link>
		<comments>http://www.digitaldogbyte.com/2010/08/20/robotlegs-modular-application-with-multiple-contexts/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 14:16:20 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[robotlegs]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=113</guid>
		<description><![CDATA[My previous post demonstrated modular programming in the Robotlegs framework using the Robotlegs modular utilities. This post will discuss a workaround that I came up with to handle inter-context communication between modules before the Robotlegs Modular Utilities were released. The benefits of using this workaround is that you can have modules in their own encapsulated [...]]]></description>
			<content:encoded><![CDATA[<p>My previous post demonstrated modular programming in the <a href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> framework using the Robotlegs modular utilities. This post will discuss a workaround that I came up with to handle inter-context communication between modules before the <a href="http://github.com/joelhooks/robotlegs-utilities-Modular" target="_blank">Robotlegs Modular Utilities</a> were released.</p>
<p>The benefits of using this workaround is that you can have modules in their own encapsulated contexts, the disadvantage is that this solution is not very scalable if you have lots of events that need to be mapped between the contexts.</p>
<p>The basic idea is to create a getter for the _eventDispatcher property in the context of each module. Once the root application has fired the creationComplete event, the handler for creationComplete needs to use the getters so that the root application can perform the necessary event mapping which will allow the two modules to communicate.</p>
<p>Here is the <a href="http://www.digitaldogbyte.com/downloads/rl_modular_multiple_contexts_demo/RL_Modular_Multiple_Contexts.html" target="_blank">demo</a> and the <a href="http://www.digitaldogbyte.com/downloads/rl_modular_multiple_contexts_demo/srcview/index.html" target="_blank">source code</a>.</p>
<p>I&#8217;ve added inline comments within the source code explaining how to map the events between the modules.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2010/08/20/robotlegs-modular-application-with-multiple-contexts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

