<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Recalibrate</title>
	<atom:link href="http://mikehoitomt.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikehoitomt.wordpress.com</link>
	<description>Self Improvement with a hot cup of Java</description>
	<lastBuildDate>Thu, 26 Jan 2012 12:40:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mikehoitomt.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Recalibrate</title>
		<link>http://mikehoitomt.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mikehoitomt.wordpress.com/osd.xml" title="Recalibrate" />
	<atom:link rel='hub' href='http://mikehoitomt.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Build-a-server</title>
		<link>http://mikehoitomt.wordpress.com/2011/06/29/build-a-server/</link>
		<comments>http://mikehoitomt.wordpress.com/2011/06/29/build-a-server/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 16:11:41 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=186</guid>
		<description><![CDATA[Whether you are interested in Node.js or not there is a really excellent beginner &#8220;book&#8221; here.  What makes the tutorial/book so interesting, and valuable, is that you end up building a web server.  Granted, Node.js is doing all of the serving of the pages but the tutorial walks you through the request/response lifecycle. It feels [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=186&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whether you are interested in Node.js or not there is a really excellent beginner &#8220;book&#8221; <a href="http://nodebeginner.org/">here</a>.  What makes the tutorial/book so interesting, and valuable, is that you end up building a web server.  Granted, Node.js is doing all of the serving of the pages but the tutorial walks you through the request/response lifecycle. It feels like you are coding &#8220;close to the metal&#8221; of the server machine, and it&#8217;s all done using familiar javascript.</p>
<p>You get started with the ubiquitous Hello World example and work your way up to a router, request handlers, and everything else that goes into a website.  The steps are small and each one is explained quite well.  You don&#8217;t need to know javascript to do the tutorial, but it helps if you have used it a bit.</p>
<p>I haven&#8217;t done much coding with PHP so if you come from a PHP background, the tutorial may be old news.  However If you come from a Ruby on Rails background the tutorial really helps to tie together a lot of what we are doing in the config/routes file and how the MVC pattern works. At the very least, regardless of your background, it&#8217;s a great introduction to Node.js.</p>
<p>It&#8217;s like a lot of things: You don&#8217;t need to understand how it works in order to get by.  But if you understand how it works, you can use it better.  This tutorial does an excellent job showing you how a web server works.  And you get to learn Node.js in the process, what could be better!</p>
<p>Here is the link to the book again: http://nodebeginner.org/</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/186/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=186&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2011/06/29/build-a-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Sencha Touch application with Ruby on Rails – Part 2</title>
		<link>http://mikehoitomt.wordpress.com/2011/04/21/sencha-touch-application-with-ruby-on-rails-%e2%80%93-part-2/</link>
		<comments>http://mikehoitomt.wordpress.com/2011/04/21/sencha-touch-application-with-ruby-on-rails-%e2%80%93-part-2/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 02:29:13 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=165</guid>
		<description><![CDATA[The source code for this application is posted on GitHub at https://github.com/hoitomt/Sencha-Tutorial Sencha has formalized the MVC pattern recently as part of the ExtJS 4 release.  Check out this link for more information. Create the Sencha Application I&#8217;m back with the Sencha portion of the application.  We are going to create the application using the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=165&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The source code for this application is posted on GitHub at https://github.com/hoitomt/Sencha-Tutorial</p>
<p>Sencha has formalized the MVC pattern recently as part of the ExtJS 4 release.  Check out this <a href="http://www.sencha.com/blog/ext-js-4-beta-3/">link</a> for more information.</p>
<h1>Create the Sencha Application</h1>
<p>I&#8217;m back with the Sencha portion of the application.  We are going to create the application using the MVC (Model View Controller) pattern</p>
<h2>Update your Rails App</h2>
<p>In your rails public/javascripts directory create the following folders.</p>
<p>app</p>
<p>app/controllers</p>
<p>app/models</p>
<p>app/views</p>
<p>Add the sencha touch folder to the public/javascripts folder.  Take a look at the Hello World application from Sencha for some assistance on downloading the zip file containing all of the applicable files.  I downloaded it and extracted the entire package into public/javascripts/.  Then I renamed the folder touch_1_0_1.  So public/javascripts/touch_1_0_1 has the following directories: docs, examples, jsbuilder, pkgs, resources, src, and test.  It also contains some of the other files that come with the Sencha touch download.</p>
<p>Now copy the stylesheet over to a directory that Rails likes.  From public/javascripts/touch_1_0_1/resources/css copy &#8220;sencha-touch&#8211;debug.css&#8221; over to public/stylesheets/.  If you did the first part of this tutorial, then you will now have scaffold.css and sencha-touch-debug-css in the public/stylesheets directory.</p>
<p>Update your index file with the references to the Sencha Touch file and stylesheet.  Here is my index file.</p>
<p><pre class="brush: xml;">

&lt;% if(mobile_device?) %&gt;

 &lt;!-- Code Viewable to mobile devices --&gt;
 &lt;%= content_for :head do %&gt;
 &lt;%= stylesheet_link_tag 'sencha-touch-debug' %&gt;
 &lt;%= javascript_include_tag 'touch_1_0_1/sencha-touch-debug' %&gt;

 &lt;style&gt;
 .synced {
 background-color: #EDE613;
 }
 &lt;/style&gt;

 &lt;% end %&gt;

&lt;% else %&gt;
 &lt;%= content_for :head do %&gt;
 &lt;%= stylesheet_link_tag 'scaffold' %&gt;
 &lt;%= javascript_include_tag :defaults %&gt;
 &lt;% end %&gt;
 &lt;h1&gt;Listing contacts&lt;/h1&gt;

 &lt;table&gt;
 &lt;tr&gt;
 &lt;th&gt;First Name&lt;/th&gt;
 &lt;th&gt;Last Name&lt;/th&gt;
 &lt;th&gt;Email&lt;/th&gt;
 &lt;th&gt;Phone&lt;/th&gt;
 &lt;th&gt;&lt;/th&gt;
 &lt;th&gt;&lt;/th&gt;
 &lt;th&gt;&lt;/th&gt;
 &lt;/tr&gt;

 &lt;% @contacts.each do |contact| %&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;%= contact.first_name %&gt;&lt;/td&gt;
 &lt;td&gt;&lt;%= contact.last_name %&gt;&lt;/td&gt;
 &lt;td&gt;&lt;%= contact.email %&gt;&lt;/td&gt;
 &lt;td&gt;&lt;%= contact.phone %&gt;&lt;/td&gt;
 &lt;td&gt;&lt;%= link_to 'Show', contact %&gt;&lt;/td&gt;
 &lt;td&gt;&lt;%= link_to 'Edit', edit_contact_path(contact) %&gt;&lt;/td&gt;
 &lt;td&gt;&lt;%= link_to 'Destroy', contact, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;% end %&gt;
 &lt;/table&gt;

 &lt;br /&gt;

 &lt;%= link_to 'New Contact', new_contact_path %&gt;

&lt;% end %&gt;

</pre></p>
<h2>Create the Sencha App</h2>
<h3>Starting point: app.js</h3>
<p>Now you should be ready to start building the application. Let&#8217;s start with the entry point into the application, the app.js file.  Put the app.js file into public/javascripts/app. The code below creates an instance of the viewport that will be used to display our panels. The <a href="http://dev.sencha.com/deploy/touch/docs/">Sencha API</a> it give some helpful information about Ext.regApplication. The Sencha API will be your BFF as you build more applications. Creating your application with the regApplication function automatically creates your app.views, app.models, app.stores, and app.controllers namespaces which makes it easy to navigate through your application</p>
<p><pre class="brush: jscript;">
Ext.regApplication(
  {
    name: 'app',
    launch: function() {
    this.views.viewport = new this.views.Viewport();
  }
});
</pre></p>
<h3>Views: Viewport.js</h3>
<p>Now let&#8217;s create the Viewport.js file.  Put the Viewport.js file in public/javascripts/app/views.  The code below sets up the main panel that will provide the navigation for all of your sub-panels.  When navigating between slides the code will actually be switching the active panel in the viewport.  The viewport below shows all of the panels in the application.  We haven&#8217;t created these yet so your application will crash if you try to run it right now.  You can go ahead and create empty files for the 5 files below (ContactsList, ContactShow, ContactEdit, ContactNew, and ContactCatalog).  Put them all into public/javascripts/app/views.</p>
<p><pre class="brush: jscript;">
//app.views.Viewport
app.views.Viewport = Ext.extend(Ext.Panel, {
  fullscreen: true,
  layout: 'card',
  cardSwitchAnimation: 'slide',
  initComponent: function() {
    Ext.apply(app.views, {
      contactsList: new app.views.ContactsList(),
      contactShow: new app.views.ContactShow(),
      contactEdit: new app.views.ContactEdit(),
      contactNew: new app.views.ContactNew(),
      contactCatalog: new app.views.ContactCatalog()
    });
    Ext.apply(this, {
      items: [
        app.views.contactsList,
        app.views.contactShow,
        app.views.contactEdit,
        app.views.contactNew,
        app.views.contactCatalog
      ]
    });
    app.views.Viewport.superclass.initComponent.apply(this, arguments);
  }
});
</pre></p>
<p>Update your index file (app/views/contacts/index.html.erb) to add the necessary imports.  Then you can run your application and you should see the empty ContactsList panel displayed.</p>
<p><pre class="brush: xml;">
&lt;%= javascript_include_tag 'app/app' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactCatalog' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactEdit' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactNew' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactShow' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactsList' %&gt;
&lt;%= javascript_include_tag 'app/views/Viewport' %&gt;
</pre></p>
<h3>Model: Contact.js</h3>
<p>Now let&#8217;s take a look at the model. Create Contact.js in public/javascripts/app/models. Our model serves three purposes:</p>
<p>1. Get data from the web server for the application</p>
<p>2. Store data locally in localstorage</p>
<p>3. Post data to the web server that has been captured on the device.</p>
<p>We&#8217;re going to do this with multiple proxies.  The Sencha proxies make it easy to persist data.  The code below defines the fields, validations, and a proxy for saving a single model instance to the web server.  I like using xml to transmit back and forth but I notice that the Sencha guys like using json. XML is more comfortable for me at the moment and it seems to work well with ROR.</p>
<p><pre class="brush: jscript;">
//Contact.js
app.models.Contact = new Ext.regModel('app.models.Contact', {
  fields: [
    {name: 'id', type: 'int'},
    {name: 'remote_id', type: 'int'},
    {name: 'synced', type: 'boolean'},
    {name: 'first_name', type: 'string'},
    {name: 'last_name', type: 'string'},
    {name: 'email', type: 'string'},
    {name: 'phone', type: 'string'}
  ],
  validations: [
    {type: 'presence', field: 'first_name'},
    {type: 'presence', field: 'last_name'}
  ],
  proxy: {
    type: 'ajax',
    url: 'contacts.xml',
    reader: {
      type: 'xml',
      record: 'contact'
    },
    writer: {
      type: 'xml',
      record: 'contact'
    }
  }
});
...
</pre></p>
<p>Now add two more stores to your model.  The first one is a local store which will help with CRUD to your local storage.  The second is a remote store that we use only to get a complete list of data from the web server to populate our catalog.</p>
<p><pre class="brush: jscript;">
//Contact.js
...
app.stores.localContacts = new Ext.data.Store({
  id: 'localContacts',
  model: 'app.models.Contact',
  proxy: {
    type: 'localstorage',
    id: 'contacts'
  }
});

app.stores.remoteContacts = new Ext.data.Store({
  id: 'remoteContacts',
  model: 'app.models.Contact',
  proxy: {
    type: 'ajax',
    url: 'contacts.xml',
    reader: {
      type: 'xml',
      root: 'contacts',
      record: 'contact'
    },
    writer: {
      type: 'xml',
      record: 'contact'
    }
  }
});
...
</pre></p>
<p>Finally we need to add the CRUD and synchronizing code. The first function app.models.save is called from the controller when the save button is clicked on the ContactNew form.  This takes all of the data from the form and persists it into local storage using the local store.  The stores work really well with models so one trick that I use is to create a new model using the data from the form.  Ext.ModelMgr.create(data, modelname) makes it easy to pass in a list of name-value pairs to create a new model instance.  The store has a really nice method (add) for persisting existing models.  Together you can pull all of your form data and persist it with only a couple of lines of code.</p>
<p><pre class="brush: jscript;">
// Contact.js
...
app.models.save = function() {
  var form = app.views.contactNew
  var params = form.getValues();
  var newcontact = Ext.ModelMgr.create(params, app.models.Contact);
  var errors = newcontact.validate();
  if (errors.isValid()) {
    app.stores.localContacts.add(newcontact);
    app.stores.localContacts.sync();
    form.reset();
    return true;
  } else {
    var errorMsg = '';
    errors.each(function(e) {
    errorMsg = errorMsg + fieldHumanize(e.field) + ' ' + e.message + &quot;&lt;br /&gt;&quot;;
    errorMsg = errorMsg ;
  });
  Ext.Msg.show({
    title: 'Error',
    msg: errorMsg,
    buttons: Ext.MessageBox.OK,
    fn: function() {
      return false;
    }
  });
}
</pre></p>
<p>Next we write the update function. This is called from the controller when the update button is clicked from the ContactEdit screen. All of the data is pulled from the form into a params variable.  The code then loops through the params and updates everything on the model.</p>
<p><pre class="brush: jscript;">
...
app.models.update = function(id) {
  var contact = app.stores.localContacts.getById(id);
  if(contact) {
    var form = app.views.contactEdit
    var params = form.getValues();
    for(var field in params) {
      console.log(&quot;field: &quot; + field + ' | value: ' + params[field]);
      contact.set(field, params[field]);
    }
    var errors = contact.validate();
    if(errors.isValid()) {
      contact.set('synced', false);
      app.stores.localContacts.sync()
      Ext.Msg.alert('Updated', 'The contact has been updated');
      return true;
    } else {
      var errorMsg = '';
      errors.each(function(e) {
      errorMsg = errorMsg + fieldHumanize(e.field) + ' ' + e.message + &quot;&lt;br /&gt;&quot;;
      errorMsg = errorMsg ;
    });
    Ext.Msg.alert('Error', errorMsg);
      return false;
    }
  } else {
    return false;
  }
}
</pre></p>
<p>Next a short delete function to remove the record from local storage only.</p>
<p><pre class="brush: jscript;">
app.models.destroy = function(id) {
  var contact = app.stores.localContacts.getById(id);
  if(contact) {
    app.stores.localContacts.remove(contact);
    app.stores.localContacts.sync();
    return true;
  } else {
    return false;
  }
}
</pre></p>
<p>Finally the sync function. After validating that the device is online the localstore is loaded with the latest data from localstorage.  Each record in the local store is evaluated to find only those records that need to be synced (synced == false).  Once we have the sync array and there are more than 0 records in the syncArray we loop through it.  NOTE: I&#8217;m using a for loop but it is actually better to use an each loop when going through the array.  To do that you would replace for(var i=0&#8230;.) with syncArray.each(function(form) {&#8230; existing code &#8230;}.  Then remove the line form = syncArray[i].</p>
<p>The pattern for syncing is as follows: use the data from the syncArray record to create a new model.  Then use the proxy on the app.models.Contact model to save the record to the web server.  This is why we have a proxy on the model, so that we can call syncModel.save and have the data synchronize with the server.  There are three callbacks: success, failure, and callback.  Success is called if the data successfully saves.  Failure is called if something goes wrong and Callback is called regardless of what happens.</p>
<p>One of the tricky things with Javascript and ExtJS is managing the asynchronous actions.  That is why the callbacks are used.  If you just call syncModel.save() and then try to pop a success message, it won&#8217;t work the way you think it would.  The save action will execute asynchronously and the code will move onto the next line while it the save is still executing.  So your alert message would display even though the save hadn&#8217;t finished.</p>
<p><pre class="brush: jscript;">
app.models.synchronizeLocalToRemote = function () {
  if(!navigator.onLine) {
    Ext.Msg.alert('Offline', 'You need to be online to sync to the web server');
    return;
  }
  console.log('Start Sync');
  var localStore = app.stores.localContacts.load();
  var syncArray = getDataToSync(localStore);
  var count = syncArray.length;
  if(count == 0) {
    Ext.Msg.show({
      title: 'Synced',
      msg: 'All contacts are synced'
    });
    return;
  }
  var syncInfo = &quot;&quot;;
  console.log(&quot;Number of items to sync: &quot; + count);

  // Show the syncing spinner
  var mask = new Ext.LoadMask(Ext.getBody(), {msg: &quot;Synchronizing&quot;});
  mask.show();

  // Sync items to remote
  for(var i = 0; i &lt; count; i++) {
    console.log(&quot;Index: &quot; + i);
    form = syncArray[i];
    var syncModel = Ext.ModelMgr.create(form.data, app.models.Contact);
    // Calling save on the model calls the remote proxy
    syncModel.save({
      success: function(result, request) {
        var id = result.data['id']
        console.log(&quot;Result ID: &quot; + id);
        console.log(&quot;Success&quot;);
        form.set('remote_id', id);
        form.set('synced', true);
        localStore.sync();
        syncInfo = 'Success: ' + form.get('first_name') + ' ' +
        form.get('last_name') + ' has been synced&lt;br /&gt;';
      },
      failure: function(result, request) {
        console.log(&quot;Exception&quot;);
        console.log(&quot;Result: &quot; + request.responseText);
        syncInfo = 'Failed: ' + form.get('first_name') + ' ' +
        form.get('last_name') + ' has been synced&lt;br /&gt;';
      },
      callback: function(result, request) {
        console.log(syncInfo);
        if(i &gt;= count - 1) {
          mask.hide();
          Ext.Msg.show({
            title: 'Complete',
            msg: syncInfo
          });
        }
      }
    });
  }
}

var getDataToSync = function(store) {
  var syncArray = new Array();
  store.each( function(form, index) {
    var isSynced = form.get('synced');
    if (!isSynced) {
      syncArray.push(form);
    }
  });
  return syncArray
}
</pre></p>
<p>Phew! Are you still with me? The code for the views is relatively straight-forward. I&#8217;ve posted the <a href="https://github.com/hoitomt/Sencha-Tutorial">source code on GitHub</a> so you can get walk through the views (public/javascripts/app/views) there.  However I want to walk through a couple of examples of following a click from the view through the controller to another view.</p>
<h3>Views and Controller: contacts.js</h3>
<p>Here is a snippet from ContactsList.js.  This is the button and handler for the &#8220;new&#8221; button on the top toolbar.  When you click on the &#8216;new&#8217; button on the toolbar the framework will take you to the controller.</p>
<p><pre class="brush: jscript;">
//ContactsList.js
...
{
  text: 'new',
  ui: 'confirm',
  handler: function() {
    Ext.dispatch({
      controller: app.controllers.contacts,
      action: 'newContact',
      animation: {type: 'slide', direction: 'left'}
    });
  }
}
...
</pre></p>
<p>The controller is in public/javascripts/app/controllers and is called contacts.js. From the newContact action in the controller we can see that the controller is setting the active panel on the viewport to the contactNew panel. One thing to note: it is setting the active panel to an <em>instance</em> of the new panel.  Notice the lower-case &#8220;c&#8221; on contactNew.  We are using the instances of the panels that were created in the Viewport code.</p>
<p><pre class="brush: jscript;">
...
newContact: function(options) {
 app.views.viewport.setActiveItem(app.views.contactNew, options.animation);
},
...
</pre></p>
<p>A more complex example of moving from panel to panel involves selecting an item from the list. From the ContactList panel you can click on an item to edit it.  There are two click handlers:  onItemDisclosure handles clicks directly on the arrow and onItemTap handles clicks on the row.  They both do the exact same thing except that onItemDisclosure has access to the actual records whereas onItemTap has to translate the record from the item.  The code below should look familiar as compared to the code above with one significant addition: We are sending an id to the controller.  The id and the animation are both transmitted to the controller in an &#8216;options&#8217; object.</p>
<p><pre class="brush: jscript;">
//ContactsList.js
...
onItemTap: function(item) {
  record = this.getRecord(item);
  Ext.dispatch({
    controller: app.controllers.contacts,
    action: 'show',
    id: record.getId(),
    animation: {type: 'slide', direction: 'left'}
  });
}
...
</pre></p>
<p>The controller uses the id from the options hash to retrieve the correct record for editing.  If a contact is found in localstorage then the contactEdit view is updated with the data.  The panel is updated by calling a method in the contactEdit view called updateWithRecord</p>
<p><pre class="brush: jscript;">
// contacts.js
...
edit: function(options) {
  var id = parseInt(options.id);
  var contact = app.stores.localContacts.getById(id);
  if(contact) {
    app.views.contactEdit.updateWithRecord(contact);
    app.views.viewport.setActiveItem(app.views.contactEdit, options.animation);
  }
},
...
</pre></p>
<p>It is a little bit magical actually. As long as you are using a FormPanel it is really easy to update the fields with data from an existing record.  By calling the &#8216;load&#8217; method (this.load(record)) on the FormPanel and passing it the record each of the fields is mapped to the record object using the &#8216;name&#8217; of the field.  For example if the first_name of the record is populated it will automatically fill in the textfield where name: &#8216;first_name&#8217;.  It will do this for all fields where the name equals the field from the record.  It is good to keep this in mind when designing your forms: Make sure to name your fields that same as your model fields.</p>
<p><pre class="brush: jscript;">
// ContactEdit.js
...
updateWithRecord: function(record) {
  this.load(record);
  var topToolbar = this.getDockedItems()[0];
  topToolbar.getComponent('cancel').record = record;

  var bottomToolbar = this.getDockedItems()[1];
  bottomToolbar.getComponent('save').record = record;
  bottomToolbar.getComponent('save').form = this;
}
</pre></p>
<p>Make sure to add references to the controller and model in your index.html.erb.  Take care to add them in the following order. The Sencha framework will throw an error if the data for the ContactList is not available when you try to display the list. So it is important to load the model first, then the views.</p>
<p><pre class="brush: xml;">
&lt;%= javascript_include_tag 'app/app' %&gt;
&lt;%= javascript_include_tag 'app/util' %&gt;
&lt;%= javascript_include_tag 'app/models/Contact' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactCatalog' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactEdit' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactNew' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactShow' %&gt;
&lt;%= javascript_include_tag 'app/views/ContactsList' %&gt;
&lt;%= javascript_include_tag 'app/views/Viewport' %&gt;
&lt;%= javascript_include_tag 'app/controllers/contacts' %&gt;
</pre></p>
<p>That is pretty much it for our application.  There are some fun things in the source code, like a catalog where you can view a list of items from the server on your mobile device.  Then touch the item to download it to the device for manipulation.  Please post any questions or comments and I&#8217;ll try to help out.</p>
<p>Thanks for reading!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=165&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2011/04/21/sencha-touch-application-with-ruby-on-rails-%e2%80%93-part-2/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Sencha Touch application with Ruby on Rails &#8211; Part 1</title>
		<link>http://mikehoitomt.wordpress.com/2011/03/10/sencha-touch-application-with-ruby-on-rails-part-1/</link>
		<comments>http://mikehoitomt.wordpress.com/2011/03/10/sencha-touch-application-with-ruby-on-rails-part-1/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 19:10:45 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=129</guid>
		<description><![CDATA[Hi, As promised I&#8217;m back with an example application written in Ruby on Rails and Javascript built on the Sencha Touch framework.  This is a Contacts application with a &#8220;checkout&#8221; functionality.  I&#8217;ve had to split it into two blog posts due to size. This is what we are trying accomplish: Add a new contact via [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=129&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>As promised I&#8217;m back with an example application written in Ruby on Rails and Javascript built on the Sencha Touch framework.  This is a Contacts application with a &#8220;checkout&#8221; functionality.  I&#8217;ve had to split it into two blog posts due to size. This is what we are trying accomplish:</p>
<ul>
<li>Add a new contact via the Web interface or via the device (pad, phone) interface</li>
<li>Contacts that have been added on the device are stored in local storage</li>
<li>Pressing &#8220;Sync&#8221; on the device will push unsync&#8217;ed data from the device to the web storage</li>
<li>List all contacts that are stored locally on the phone</li>
<li>List all contacts that are stored on the server in the &#8220;Catalog&#8221;</li>
<li>Upon clicking an entry in the Catalog it is checked out to your local storage</li>
</ul>
<p>Here are some screen shots of the final product &#8211; Yellow contacts are un-synced.  Catalog not shown.</p>
<div>
<p><a href="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-10-30-36-am.png"><img class="alignleft size-medium wp-image-130" title="Screen shot 2011-03-04 at 10.30.36 AM" src="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-10-30-36-am.png?w=159&#038;h=300" alt="" width="159" height="300" /></a></p>
<p><a href="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-10-32-39-am1.png"><img class="alignleft size-medium wp-image-132" title="Screen shot 2011-03-04 at 10.32.39 AM" src="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-10-32-39-am1.png?w=159&#038;h=300" alt="" width="159" height="300" /></a></p>
<p><a href="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-11-59-49-am.png"><img class="alignleft size-medium wp-image-133" title="Screen shot 2011-03-04 at 11.59.49 AM" src="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-11-59-49-am.png?w=159&#038;h=300" alt="" width="159" height="300" /></a></p>
<p><a href="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-12-41-30-pm1.png"><img class="alignleft size-medium wp-image-143" title="Screen shot 2011-03-04 at 12.41.30 PM" src="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-12-41-30-pm1.png?w=159&#038;h=300" alt="" width="159" height="300" /></a></p>
</div>
<p style="clear:both;">Let&#8217;s get started</p>
<p style="clear:both;">Side Note: I recommend using Safari for development of Sencha Touch applications. Safari&#8217;s Develop menu gives it an advantage over other browsers in my opinion.  Although I&#8217;ve heard Chrome is quite good as well:</p>
<div style="clear:both;">
<ol>
<li>If you do not see a Develop menu at the top of the screen between Bookmarks and Window go to Preferences (Edit/Preferences on Win, Safari/Preferences on Mac).  From the Preferences menu select Advanced.  From the Advanced page select &#8220;Show Develop menu in menu bar&#8221;</li>
<li>From Develop/User Agent you can view the site as if you are viewing it from a mobile device.  I&#8217;m not sure if other browsers have this but it is a killer feature</li>
<li>From Develop/Show Web Inspector you can view a very nice debugger panel.  The Web Inspector panel provides a tab that displays the local storage.  It also provides a console tab where you can type in JavaScript command and test code against you application. This has proved to be invaluable when trying to debug the Sencha Touch application.</li>
</ol>
</div>
<h2 style="clear:both;">Rails Application</h2>
<h3>Create the Rails Application</h3>
<p>First thing, create your Rails app. The Ruby On Rails server app in this example is minimal.  It was created as a scaffold and the controller has been customized to handle the xml going back and forth. From the command line the following will create your Rails application and database.</p>
<p><pre class="brush: bash;">
$ rails new contacts
$ cd contacts
$ rails g scaffold contact first_name:string last_name:string email:string phone:string
$ rake db:migrate
$ rails s
</pre></p>
<p>Navigate to http://localhost:3000.  You should see the rails welcome page.  Next we&#8217;re going to update routes.rb so that the root points to your index page for your contacts.  First delete the index.html page in the public directory. Then update config/routes.rb to set the root to contacts/index.</p>
<p><pre class="brush: ruby;">
ContactsDemo::Application.routes.draw do
  root :to =&gt; 'contacts#index'
  resources :contacts
end
</pre></p>
<h3>Update the Controller</h3>
<p>Open up app/controllers/contacts_controllers.rb. The controller needs to be updated so that it plays nicely with your Sencha Touch app.  There are two things you&#8217;re trying to do with the Rails code:</p>
<ol>
<li>Update the index so it delivers an xml list of your contacts</li>
<li>Update the create so that new contacts are created or updated accordingly.  NOTE: This is a very high-level approach to synchronizing records between two  data sources. If you are familiar with Version Control (Subversion and  Git) then you have seen synchronization done at a very deep level. This  application will not check at the field level for collisions or anything  on that order. Simply put: The application will treat any incoming  record as the latest and will update the online DB with the entire  record.</li>
</ol>
<p>Index (Update: add dasherize =&gt; false.  This will make your xml send first_name rather than first-name)</p>
<p><pre class="brush: ruby;">
def index
  @contacts = Contact.all
  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render : xml =&gt; @contacts, :dasherize =&gt; false }
                # Note: WordPress workaround: do not put a space between the colon and xml
                # Wordpress was doing funny things with colonxml so I had to put a space
  end
end
</pre></p>
<p>Add 3 new methods to the end of the controller: parse_sencha_xml, update_record, and parse_contact_params</p>
<p><pre class="brush: ruby;">
def parse_sencha_xml
  p_hash = params[:xmlData][:contact]
  return nil if p_hash.nil? || p_hash.empty?
  # call update if the remote_id is populated, means it's already in the db
  if p_hash['remote_id'].to_i &gt; 0
    return update_record(p_hash)
  end
  contact = Contact.create!(parse_contact_params(p_hash))
  return contact
end

def update_record(p_hash)
  id = params[:xmlData][:contact]['remote_id']
  c = Contact.find(id)
  update_params = parse_contact_params(p_hash)
  c.update_attributes(update_params)
  return c
end

def parse_contact_params(p_hash)
  contact_hash = Hash.new
  attr = Contact.new.attributes
  p_hash.each do |key, value|
    if (key == 'id' || key == 'remote_id' )
    # skip, this is the device PK or the db PK.  The db PK has already been captured
    elsif attr.has_key?(key)
      contact_hash[key] = value
    end
  end
  return contact_hash
end
</pre></p>
<p>Finally, update the Create method to use the new methods. It will now look for matching records before adding a new record.  If it finds one, it will update it.  Update create so that it calls the new methods</p>
<p><pre class="brush: ruby;">
def create
  respond_to do |format|
    format.html {
      @contact = Contact.new(params[:contact])
      if @contact.save
        redirect_to root_path
      else
        render :action =&gt; 'new'
      end
    }
    format.xml {
      @contact = parse_sencha_xml
      render : xml =&gt; @contact, :status =&gt; :created, :dasherize =&gt; false
             # Note: WordPress workaround: do not put a space between the colon and xml
# Wordpress was doing funny things with colonxml so I had to put a space
    }
  end
end
</pre></p>
<h3>Routing and viewing both Mobile and Standard sites</h3>
<p>Now that our controller is updated there are a few things we need to do to take care of routing and add the ability to view mobile or standard sites.</p>
<p>Update app/controller/application_controller to allow for mobile or standard display.  The following is pulled directly from Railscasts episode 199.  Rails will evaluate the user_agent from the incoming request and true if it contains &#8220;Mobile&#8221; (Android or iOS) or &#8220;webOS&#8221; (Palm)</p>
<p><pre class="brush: ruby;">
class ApplicationController &lt; ActionController::Base
  helper :all
  protect_from_forgery

  private
    def mobile_device?
      user_agent = request.user_agent
      user_agent =~ /Mobile|webOS/
    end
    helper_method :mobile_device?

end
</pre></p>
<p>Update the view so that the page displays in a browser.  First update the index page.  The new mobile_device? method is used to determine which part of the index page to display.</p>
<p><pre class="brush: ruby;">
&lt;% if(mobile_device?) %&gt;

 &lt;!-- Code Viewable to mobile devices --&gt;
 &lt;%= content_for :head do %&gt;
 &lt;%= stylesheet_link_tag 'sencha-touch-debug' %&gt;
 &lt;%= javascript_include_tag 'touch_1_0_1/sencha-touch-debug' %&gt;

 &lt;%= javascript_include_tag 'app/app' %&gt;
 &lt;%= javascript_include_tag 'app/util' %&gt;
 &lt;%= javascript_include_tag 'app/models/Contact' %&gt;
 &lt;%= javascript_include_tag 'app/views/ContactCatalog' %&gt;
 &lt;%= javascript_include_tag 'app/views/ContactEdit' %&gt;
 &lt;%= javascript_include_tag 'app/views/ContactNew' %&gt;
 &lt;%= javascript_include_tag 'app/views/ContactShow' %&gt;
 &lt;%= javascript_include_tag 'app/views/ContactsList' %&gt;
 &lt;%= javascript_include_tag 'app/views/Viewport' %&gt;
 &lt;%= javascript_include_tag 'app/controllers/contacts' %&gt;

 &lt;style&gt;
 .synced {
 background-color: #EDE613;
 }
 &lt;/style&gt;

 &lt;% end %&gt;

&lt;% else %&gt;
 &lt;%= content_for :head do %&gt;
 &lt;%= stylesheet_link_tag 'scaffold' %&gt;
 &lt;%= javascript_include_tag :defaults %&gt;
 &lt;% end %&gt;

 &lt;!--Add code from index.html.erb --&gt;
 ...

&lt;% end %&gt;

</pre></p>
<p>Next update app/views/layouts/application.html.erb to remove a couple of lines that you don&#8217;t need for mobile browsers</p>
<p><pre class="brush: ruby;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
 &lt;title&gt;ContactsDemo&lt;/title&gt;
 &lt;%= csrf_meta_tag %&gt;
 &lt;%= yield :head %&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;%= yield %&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre></p>
<p>That&#8217;s it for the rails application.  When you view the page in a standard browser you should see the index page that lists all of your contacts.  If you change the User Agent (Safari) to Mobile Safari 4.1 you will see a blank gray screen. If something appears to explode when you switch to Mobile Safari remove the javascript imports that start with &#8216;app/&#8230;  I can&#8217;t remember if Safari gets made if you ask it to import something that is not there. I will be posting the Sencha Touch application next time.</p>
<p>Thanks for reading!</p>
<p>References:</p>
<p><a href="http://www.sencha.com/learn/Tutorial:A_Sencha_Touch_MVC_application_with_PhoneGap" target="_blank">Excellent MVC Tutorial with Sencha Touch and PhoneGap</a></p>
<p><a href="http://www.railscasts.com/" target="_blank">Railscasts</a> episodes 199, 247, and 248 - by Ryan Bates.  Totally amazing gift of time, energy, and knowledge from Ryan, an absolute must watch for Rails developers.  If you want to do it in Rails, Ryan has probably already done it and has a nice succinct video that explains it to you.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=129&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2011/03/10/sencha-touch-application-with-ruby-on-rails-part-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>

		<media:content url="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-10-30-36-am.png?w=159" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 10.30.36 AM</media:title>
		</media:content>

		<media:content url="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-10-32-39-am1.png?w=159" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 10.32.39 AM</media:title>
		</media:content>

		<media:content url="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-11-59-49-am.png?w=159" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 11.59.49 AM</media:title>
		</media:content>

		<media:content url="http://mikehoitomt.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-12-41-30-pm1.png?w=159" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 12.41.30 PM</media:title>
		</media:content>
	</item>
		<item>
		<title>Mobile Apps: Native v Web-based</title>
		<link>http://mikehoitomt.wordpress.com/2011/03/03/mobile-apps-native-v-web-based/</link>
		<comments>http://mikehoitomt.wordpress.com/2011/03/03/mobile-apps-native-v-web-based/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 19:05:32 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=125</guid>
		<description><![CDATA[I&#8217;m getting into development for mobile devices specifically iOS and Android devices. The first thing a developer needs to ask themselves when going down this road is: What language am I going to use? From the time that the iPhone came out up until recently (Fall 2010) the answer was easy. If you wanted to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=125&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m getting into development for mobile devices specifically iOS and Android devices.  The first thing a developer needs to ask themselves when going down this road is: What language am I going to use?  From the time that the iPhone came out up until recently (Fall 2010) the answer was easy.  If you wanted to give your users the best experience, you went native.  Whether it be iOS or Android: Native was the only way to develop a decent app.</p>
<p>However 3 recent developments have changed the game: 1) HTML5, 2) The introduction of version 1.0 of the <a href="http://www.sencha.com/">Sencha Touch</a> framework, and 3) Major <a href="http://www.webkit.org/blog/189/announcing-squirrelfish/" target="_blank">performance increases</a> in WebKit and Google V8 based browsers.  When you combine these technology introductions/improvements with the improvement in wrapper technologies like <a href="http://www.phonegap.com/" target="_blank">PhoneGap</a> and Titanium from <a href="http://www.appcelerator.com/" target="_blank">Appcelerator</a> and we now have real alternatives when it comes to developing applications for Mobile devices. Even venerated application design shops like <a href="http://37signals.com/" target="_blank">37Signals</a> have <a href="http://37signals.com/svn/posts/2761-launch-basecamp-mobile" target="_blank">switched over </a>to Web-based applications for mobile.</p>
<p>The benefits are obvious and many others have written very nice articles explaining the differences and pros/cons (<a href="http://monolithinteractive.com/2011/02/04/web-or-native/" target="_blank">One of my favs</a>).  However here is my two cents (after all, that&#8217;s why you&#8217;re here). Write Once/Deploy Anywhere is great and no app stores is great but to me the primary benefit is Fun!  I&#8217;m a Java programmer in my day job, and it&#8217;s a great language for paying the bills.  But it is not a fun language for coding.</p>
<p>Full disclosure: My Android programming experience amounts to coding along with some tutorials&#8230; And it sucked!  Writing XML is horrible and coding esoteric handlers in Java with inner classes to handle behavior and UI rendering is non-intuitive at its best and absolutely confusing and non-understandable at its worst.  After one day I was so sick of writing android:blah blah blah.  I&#8217;ve coded Windows Mobile apps in C# with the same feelings.  It is not fun at all.  These languages are great as powerhouse engines in IT back rooms but they are not great for Consumer facing UI design.</p>
<p>Contrast that with the Sencha Touch framework where within a couple hundreds lines of code you can have a beautiful UI complete WITH connectivity to a Web-based data store that runs on iOS and Android and there&#8217;s no comparison.  Now that the supporting technologies (HTML5 and WebKit) are catching up it&#8217;s wonderful to have real alternatives.</p>
<p>In my next post I&#8217;ll walk through a Sencha Touch application with a Ruby on Rails backend.  It is a simple contacts application that stores data locally and syncronizes to a Rails Web Store.  Check back soon&#8230;</p>
<p>Thanks for reading</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=125&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2011/03/03/mobile-apps-native-v-web-based/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Sencha, Rails3, Forms, and the authenticity token</title>
		<link>http://mikehoitomt.wordpress.com/2011/02/16/sencha-rails3-forms-and-the-authenticity-token/</link>
		<comments>http://mikehoitomt.wordpress.com/2011/02/16/sencha-rails3-forms-and-the-authenticity-token/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 04:05:45 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=118</guid>
		<description><![CDATA[I&#8217;m playing with Sencha Touch right now in a Rails app.  One of the things that hung me up for a bit was the authenticity token that is required with POSTing form data to the rails controller.  Here is how I did it. In the Sencha file where you declare your FormPanel capture the Rails [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=118&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m playing with Sencha Touch right now in a Rails app.  One of the things that hung me up for a bit was the authenticity token that is required with POSTing form data to the rails controller.  Here is how I did it.</p>
<p>In the Sencha file where you declare your FormPanel capture the Rails csrf_token as a variable by adding the following:<br />
<code>var csrf_token = document.getElementsByName("csrf-token")[0].getAttribute("content");</code><br />
In your FormPanel create a hidden field to submit the token to the controller<br />
<code>items: [<br />
{<br />
xtype: 'hiddenfield',<br />
name: 'authenticity_token',<br />
value: csrf_token<br />
},<br />
... more items ]<br />
</code></p>
<p>Now when you submit the form your authenticity token will be submitted and you can keep the cross-site-scripting forgery protection that Rails provides</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=118&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2011/02/16/sencha-rails3-forms-and-the-authenticity-token/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Excellent Reference Materials</title>
		<link>http://mikehoitomt.wordpress.com/2010/12/12/excellent-reference-materials/</link>
		<comments>http://mikehoitomt.wordpress.com/2010/12/12/excellent-reference-materials/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 17:52:52 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Observations]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Self Improvement]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=115</guid>
		<description><![CDATA[I have recently encountered two excellent resources: 1). Michael Hartl&#8217;s tutorial on Rails3.  This is an excellent overview of Rails3, Test Driven Development, and the most popular tools for developing applications in Ruby on Rails.  This tutorial is really for anyone that is involved with producing applications for the Internet.  If you are a graphic [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=115&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have recently encountered two excellent resources:</p>
<p>1). <a href="http://railstutorial.org/" target="_blank">Michael Hartl&#8217;s tutorial on Rails3</a>.  This is an excellent overview of Rails3, Test Driven Development, and the most popular tools for developing applications in Ruby on Rails.  This tutorial is really for anyone that is involved with producing applications for the Internet.  If you are a graphic designer it will help you learn to start adding database functionality to your sites.  If you are a developer the tutorial will introduce you to the best language/framework available for creating web-based applications (Ruby on Rails).  And if you already know Ruby On Rails the tutorial is truly like &#8220;looking over the shoulder of an expert RoR programmer&#8221; as the quotes claim.  Fantastic and well worth the $95 for book and videos.</p>
<p>2). <a href="http://www.amazon.com/Intelligent-Entrepreneur-Graduates-Successful-Entrepreneurship/dp/0805091661/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1292175317&amp;sr=1-1" target="_blank">The Intelligent Entrepreneur</a> by Bill Murphy Jr. I came across this book accidentally when my wife brought it home from the library for herself.  I picked it up and started reading and couldn&#8217;t put it down. The title of the book sounds stuffy and the quotes don&#8217;t make it seem like it is going to be an inspiring read but this is an excellent book for anybody that has entrepreneurial dreams.  The stories are inspiring and show you 3 ways in which businesses can be started.  They also form an anecdotal account of the business climate of the late 90&#8242;s early 00&#8242;s, most notably the Internet boom and collapse.  It is fascinating to read about actual entrepreneurs dealing with the challenges of that time.</p>
<p>One particular line prompted me to write this blog post.  On the second to last page of the book he refers to a book written by a Harvard Business School professor that tries to &#8220;show readers how to juggle &#8230; the four key elements in work and life: happiness, achievement, significance, and legacy.&#8221; That line nailed it for me for that is exactly what what I&#8217;m searching for.  I have asked myself the question often: Why do I want to run my own business? I have a great life with a well-paying job and low stress. After reading that line I realized that I only have 1 of the 4 (happiness). I want them all. In my opinion those four factors define complete self-fulfillment.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=115&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2010/12/12/excellent-reference-materials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Calendar Date Select in Ruby on Rails 2.3.5</title>
		<link>http://mikehoitomt.wordpress.com/2010/05/15/calendar-date-select-in-ruby-on-rails-2-3-5/</link>
		<comments>http://mikehoitomt.wordpress.com/2010/05/15/calendar-date-select-in-ruby-on-rails-2-3-5/#comments</comments>
		<pubDate>Sat, 15 May 2010 04:41:04 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=106</guid>
		<description><![CDATA[Calendar Date Select is an excellent date picker for Ruby on Rails.  I didn&#8217;t create or figure out any of the following.  This is merely a combination/re-blogging of various other posts, including instructions from the calendar date select home page Get the gem of calendar date select: &#8216;gem install calendar_date_select&#8217; Update your project&#8217;s environment.rb to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=106&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Calendar Date Select is an excellent date picker for Ruby on Rails.  I didn&#8217;t create or figure out any of the following.  This is merely a combination/re-blogging of various other posts, including instructions from the calendar date select <a href="http://code.google.com/p/calendardateselect/">home page</a></p>
<ol>
<li> Get the gem of calendar date select: &#8216;gem install calendar_date_select&#8217;</li>
<li>Update your project&#8217;s environment.rb to include the calendar_date_select gem: &#8216;config.gem &#8220;calendar_date_select&#8221; &#8216;</li>
<li>Unpack the gems to your project.  This is not required but it makes life easier: &#8216;rake gems:unpack&#8217;</li>
<li>Start your server and navigate to your home page to make sure everything is working.</li>
<li>The version in the gem has a line that needs to be updated for Rails 2.3.5.  If you get the error<em> calendar_date_select undefined method `calendar_date_select_includes&#8217;</em> when you start the server and navigate the site you need to update the calendar_date_select file.
<ol>
<li>Go to project_root\vendor\gems\calendar_date_select-1.16.1\lib and update line 5 of calendar_date_select.rb.</li>
<li>Before Change: if Object.const_defined?(:Rails) &amp;&amp; File.directory?(<strong>Rails.root.to_s + &#8220;/public&#8221;</strong>)</li>
<li>After Change: if Object.const_defined?(:Rails) &amp;&amp; File.directory?(<strong>Rails.public_path</strong>)</li>
<li>Thanks for this suggestion goes to this <a href="http://markmail.org/message/grpcwqumax2frzcw">guy</a></li>
</ol>
</li>
<li>In your layout or page add references to the default javascript files and the calendar date select files
<ol>
<li>Put this one first: &lt;%= javascript_include_tag :defaults %&gt;</li>
<li>&lt;%= calendar_date_select_includes “silver” %&gt;</li>
</ol>
</li>
<li>Check out the calendar_date_select <a href="http://electronicholas.com/calendar">demo page</a> for examples and code snippets.</li>
<li>Another excellent <a href="http://blog.beigesunshine.com/2007/08/08/extremely-simple-calendar-integration-for-rails/">blog post</a> reference from the calendar date select <a href="http://code.google.com/p/calendardateselect/">home page</a></li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=106&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2010/05/15/calendar-date-select-in-ruby-on-rails-2-3-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing Ruby on Rails and Heroku for Windows XP</title>
		<link>http://mikehoitomt.wordpress.com/2010/01/16/installing-ruby-on-rails-and-heroku-for-windows-xp/</link>
		<comments>http://mikehoitomt.wordpress.com/2010/01/16/installing-ruby-on-rails-and-heroku-for-windows-xp/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 05:05:04 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=99</guid>
		<description><![CDATA[Hello, The following is intended to be a complete guide for getting up and running on Ruby on Rails, Heroku, git and the other supporting players on Windows XP.  I wrote this guide because I was excited about Heroku but I could not get it to work.  I started in a virtual machine running ubuntu [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=99&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>The following is intended to be a complete guide for getting up and running on Ruby on Rails, Heroku, git and the other supporting players on Windows XP.  I wrote this guide because I was excited about Heroku but I could not get it to work.  I started in a virtual machine running ubuntu but couldn&#8217;t get the gems to work.  Then I tried cygwin and that didn&#8217;t work.  Finally I found a couple of key posts that solved the windows install.  The following is not of my own technical expertise.  It is merely a compilation of what was found via some Google searches and the results of my trials and errors.</p>
<p><a href="http://mikehoitomt.files.wordpress.com/2010/01/windows_heroku_install.pdf">Click here to open the overview</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=99&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2010/01/16/installing-ruby-on-rails-and-heroku-for-windows-xp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Wild hair up my&#8230;.</title>
		<link>http://mikehoitomt.wordpress.com/2009/11/11/wild-hair-up-my/</link>
		<comments>http://mikehoitomt.wordpress.com/2009/11/11/wild-hair-up-my/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 03:25:59 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=94</guid>
		<description><![CDATA[Two posts in one day, oh you lucky readers.  This one is really more of a rant on Java Enterprise.  I think I&#8217;ve said this before but here it is again: JAVA ENTERPISE/J2EE IS NOT FOR BEGINNERS.  It isn&#8217;t even for beginning programmers.  The complexity of the Java Enterprise software suite is absolutely mind-boggling. I&#8217;ve [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=94&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Two posts in one day, oh you lucky readers.  This one is really more of a rant on Java Enterprise.  I think I&#8217;ve said this before but here it is again: JAVA ENTERPISE/J2EE IS NOT FOR BEGINNERS.  It isn&#8217;t even for beginning programmers.  The complexity of the Java Enterprise software suite is absolutely mind-boggling.</p>
<p>I&#8217;ve just started as a brand-spanking new developer at my employer and I was blown away by how complex our application was.  I thought I understood MVC frameworks and how Java Enterprise interacted with them but I didn&#8217;t.  As a quick sample here are three design patterns that we use:</p>
<ol>
<li>Struts where form actions from the .jsp pages are tied to the java Command classes using an XML page.  The data from the .jsp page populates a Value Object (VO).</li>
<li>Then the Command class calls a Delegate which calls a Session Bean which calls a Business Object (BO).  The business logic is mostly located in the BO but some of it is sprinkled into the Session Bean.  Once the BO gets through with validating the data from the VO.</li>
<li>The BO then calls the DAO to persist the data to our database</li>
</ol>
<p>I&#8217;m seriously not trying to make this sound complex, that is as easy as I can write it.  This is my favorite: Command -&gt; Delegate -&gt; Session Bean -&gt; BO -&gt; DAO.  5 classes!</p>
<p>Please understand; I&#8217;m not bashing our setup.  I&#8217;ve been in the work force long enough to know that when you encounter, what appears to be, overly complicated processes/designs there were very good reasons and a bunch of really smart people behind the design and implementation. And just like the old mainframe world, due to the cost of changing, many of us new programmers are going to have to learn the existing code so we can remain gainfully employed</p>
<p>The amazing thing is how early in the evolution of software we really are. It&#8217;s encouraging to see guys like <a href="http://www.adam-bien.com/roller/">Adam Bien</a> writing really great posts about how to use EJB 3.0 and Java5/6 to greatly simplify your code.  Java Enterprise is not that far removed from Cobol, which is not that far removed from punch card stacks.  It feels like quantum leaps because each one is so much better than it&#8217;s predecessor.</p>
<p>We are still mostly at the mercy of the computer&#8217;s native tongue when it comes to writing software.  The next twenty years will be very exciting as new languages and hardware are created so that we can get the computer to start understanding our language for a change.</p>
<p>public class StoreFormData {</p>
<p>Take first name, last name, and address;</p>
<p>Store them in a place where I can retrieve them later;</p>
<p>Please make sure the zip code, city, and state are valid with each other;</p>
<p>And one more thing, please make sure it is a valid phone number;</p>
<p>And if anybody else needs this data while I&#8217;m using it, don&#8217;t let them have it until I&#8217;m done;</p>
<p>Thanks</p>
<p>}</p>
<p>That&#8217;s what user friendly software looks like <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=94&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2009/11/11/wild-hair-up-my/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
		<item>
		<title>Entrepreneur thoughts &#8211; Albom Column</title>
		<link>http://mikehoitomt.wordpress.com/2009/11/11/entrepreneur-thoughts-albom-column/</link>
		<comments>http://mikehoitomt.wordpress.com/2009/11/11/entrepreneur-thoughts-albom-column/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 02:22:00 +0000</pubDate>
		<dc:creator>hoitomt</dc:creator>
				<category><![CDATA[Observations]]></category>
		<category><![CDATA[Self Improvement]]></category>

		<guid isPermaLink="false">http://mikehoitomt.wordpress.com/?p=91</guid>
		<description><![CDATA[It&#8217;s been a long time since my last post.  It&#8217;s funny, right about the time I want to start posting every day, I end up not posting for over two months.  I started my third Java class and transferred over to a new position at work as a developer so needless to say, it has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=91&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since my last post.  It&#8217;s funny, right about the time I want to start posting every day, I end up not posting for over two months.  I started my third Java class and transferred over to a new position at work as a developer so needless to say, it has been a busy Fall.</p>
<p>Mitch Albom inspired me to write today.  His <a href="http://www.freep.com/article/20091108/COL01/911080476/1082/Your-face-in-lights-in-Times-Square----just-buy-this-T-shirt">column</a> today about fame was excellent and it pertains to business and entrepreneurship as well.  The best part of the column is when he states &#8220;Didn&#8217;t you once have to DO something to become famous? Now being famous IS doing something. The most important currency in this country is not measured on green paper. It&#8217;s measured by how many people point at you and say, &#8220;Aren&#8217;t you &#8230;?&#8221;"</p>
<p>To me this is almost the same thing as Twitter and Facebook and their ilk being considered businesses.  The comment could easily be re-written to say: &#8220;Didn&#8217;t you once have to make money to be considered a business?  Now having &#8220;customers&#8221; is being in business.  The most important currency in this country is not measured on gree paper.  It&#8217;s measured by how many people point at your website and say, &#8220;I&#8217;m with them&#8230;&#8221;"</p>
<p>The whole premise of their business is to attract more customers.  Just like Albom&#8217;s column where the whole premise of Fame is to be seen by people, not necessarily to have any talent, skill, or other exceptional quality.  They don&#8217;t make money (enough to justify their valuations), nor do they have any concrete plans to make money.  Yet the fact that they have tons of users makes them &#8220;Famous&#8221;, which in this sense means that they are great businesses which attract millions of dollars in investments.</p>
<p>At the core of these businesses is a single person that was in possession of one key element: TIME.  Evan Williams sold Pyra Labs (Blogger) to Google for enough money to buy him all the time in the world.  With that time he created Twitter.  Mark Zuckerberg was a student at Harvard when he created Facebook, with enough free time on his hands to create a cool app for his friends to stay in touch with one another.  In both of these cases, and many others, the founder was wealthy with either time, or enough money to buy time.  Take a look at the stories in Inc. magazine once.  Most of the founder stories are about people that were successful before they were successful.</p>
<p>Back to the Albom point: With time, and in most cases money, the business doesn&#8217;t need to make money.  The founder is just fine with banging away on it until something better comes along or until enough people find his cool time-killer.  This is a sobering fact for a lot of us wanna-be entrepreneurs with day jobs and families.  Time is something we don&#8217;t have.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikehoitomt.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikehoitomt.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikehoitomt.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikehoitomt.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikehoitomt.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikehoitomt.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikehoitomt.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikehoitomt.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikehoitomt.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikehoitomt.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikehoitomt.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikehoitomt.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikehoitomt.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikehoitomt.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikehoitomt.wordpress.com&amp;blog=8590528&amp;post=91&amp;subd=mikehoitomt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikehoitomt.wordpress.com/2009/11/11/entrepreneur-thoughts-albom-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7aefd971d0d6e7bcfc64ad5abcd3c0ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoitomt</media:title>
		</media:content>
	</item>
	</channel>
</rss>
