<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;p&gt;A &lt;i&gt;property path&lt;/i&gt; is a string that is used to reference some property in SproutCore.  For example the property path:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Contacts.contactController.content&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Refers to the &amp;#8220;content&amp;#8221; property on the &lt;code&gt;Contacts.contactController&lt;/code&gt; object.&lt;/p&gt;
&lt;p&gt;You use property paths in SproutCore when you setup bindings and observers and to get and set properties on objects.  The following show examples of using property paths:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
Contacts.selectedContactController = SC.ObjectController.extend({

   // Refers to the &quot;selection&quot; property on the Contacts.contactsController object.
   contentBinding: &quot;Contacts.contactsController.selection&quot;,

   // Observes the &quot;emailAddress&quot; property on the this object (Contacts.selectedContactController)
   emailAddressObserver: function() {
     this.getNewAddressValue() ;
  }.observes(&quot;emailAddress&quot;), 

  getNewAddressValue: function() {
      // gets the &quot;value&quot; property on the this.emailAddress object.
     var addresses = this.getPath('emailAddress.value') ;
  }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Types of Property Paths&lt;/h1&gt;
&lt;p&gt;SproutCore understands a variety of property paths.  Most of them can be used anywhere a property path is needed, but some have meaning in special circumstances:&lt;/p&gt;
&lt;h3&gt;Simple Properties&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;&quot;property&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;A simple property path consists of just a property name.  In SproutCore documentation this is sometimes called a property key.  A simple property path always refers to the property on whatever object you are references.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Examples Here&lt;/i&gt;&lt;/p&gt;
&lt;h3&gt;Absolute Properties&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;&quot;Namespace.object.property&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;An absolute property path names both the object and the property in the path.  It always contains at least one period and does not start with a period.  Everything up to the last period is treated as an absolute path to an object.  In the example above, the object is &amp;#8220;Namespace.object&amp;#8221; and the property is &amp;#8220;property&amp;#8221;.&lt;/p&gt;
&lt;p&gt;You use this most often when setting up bindings and referencing application views.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Examples Here&lt;/i&gt;&lt;/p&gt;
&lt;h3&gt;Relative Properties&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;&quot;.object.property&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;A relative property is a variation on the absolute path.  Like absolute paths, you name both the object and the property but SproutCore will start by searching the current object instead of at the global level.  For example, the above property&amp;#8217;s object would be &amp;#8220;this.object&amp;#8221; while the property would be &amp;#8220;property&amp;#8221;.&lt;/p&gt;
&lt;p&gt;This form is used very rarely.  If you find yourself using this pattern often, you probably should consider using bindings.&lt;/p&gt;
&lt;h3&gt;Chained Properties&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;&quot;Namespace.object*anotherObject.property&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&quot;*anotherObject.property&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Both Absolute and and Relative property paths can use a special variant called a &amp;#8220;chained property&amp;#8221;.  Regular property paths are converted to an object/property reference at the time that you use them.  This means, for example, if you setup a binding like:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;valueBinding: &quot;Contacts.selectedContact.emailAddress.value&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The object for this property will be whatever is at &amp;#8220;Contacts.selectedContact.emailAddress&amp;#8221;.  But what if the selected contact changes?  Since the binding was setup earlier in the application, the binding will not update to reflect the address change.  In this case, you can use a chained property:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;valueBinding: &quot;Contacts.selectedContact*emailAddress.value&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This tells SproutCore that you expect the emailAddress to change and you would like to monitor changes for both emailAddress &lt;span class=&quot;caps&quot;&gt;AND&lt;/span&gt; value for the binding.&lt;/p&gt;
&lt;p&gt;Chained property paths are a useful way to reduce the complexity of your code when you have deeply nested properties that you need to observe.  However, they can also be fairly expensive to setup and observe so you should avoid using them in &amp;#8220;hot&amp;#8221; code such as item views for collections.  They are fine to use for wiring up controllers and bits of static UI however.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Example Here&lt;/i&gt;&lt;/p&gt;
&lt;h1&gt;Related Links&lt;/h1&gt;
&lt;ul&gt;
	&lt;li&gt;[[Bindings, Properties, and Observers]]&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Comments&lt;/h1&gt;</body>
  <created-at type="datetime">2008-06-26T14:18:21-07:00</created-at>
  <id type="integer">30875</id>
  <permalink>about-sproutcore-property-paths</permalink>
  <repository-id type="integer">18944</repository-id>
  <title>About SproutCore Property Paths</title>
  <updated-at type="datetime">2008-06-26T14:36:06-07:00</updated-at>
  <user-id type="integer">11814</user-id>
</wiki>
