View Controller

  • Revision slug: Places/View_Controller
  • Revision title: View Controller
  • Revision id: 136626
  • Created:
  • Creator: adw
  • Is current revision? No
  • Comment 1 words added, 1 words removed

Revision Content

{{ draft() }}

{{ Firefox3() }}

Controllers are one component of the Places model-view-controller design.  They are responsible for enabling, disabling and performing commands based on the state of a Places view.

The built-in controller

The built-in Places views automatically use a built-in controller, which is an instance of PlacesController, a prototypical JavaScript function defined in {{ Source("browser/components/places/content/controller.js") }}.  So if you use a built-in Places view, you need not write your own controller, worry about hooking up your view to a controller, or really read the rest of this page.  You do, however, need to include PlacesController's source in your XUL document.  See Displaying Places information using views.

Places commands

The Places commands are:

placesCmd_new:bookmark
placesCmd_new:folder
placesCmd_new:livemark
placesCmd_new:separator
placesCmd_open
placesCmd_open:tab
placesCmd_open:window
placesCmd_reload
placesCmd_reloadMicrosummary
placesCmd_show:info
placesCmd_sortBy:name

PlacesController also supports the standard Edit commands:

cmd_copy
cmd_cut
cmd_delete
cmd_paste
cmd_redo
cmd_selectAll
cmd_undo

Creating custom controllers

You will need to write your own controller if you want to use commands that PlacesController does not support.  If you are not familiar with controllers, see the Commands and Updating Commands pages in the XUL tutorial.

If your set of commands contains some of those supported by PlacesController, you can use an instance of PlacesController to handle that subset, for example by using a PlacesController instance as a prototype if your controller is a JavaScript object, or by simply passing commands to a PlacesController instance.

Revision Source

<p>{{ draft() }}</p>
<p>{{ Firefox3() }}</p>
<p>Controllers are one component of the Places <a class="external" href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="external nofollow" target="_blank" title="http://en.wikipedia.org/wiki/Model–view–controller">model-view-controller</a> design.  They are responsible for enabling, disabling and performing commands based on the state of a <a href="/en/Displaying_Places_information_using_views" title="en/Displaying_Places_information_using_views">Places view</a>.</p>
<h2>The built-in controller</h2>
<p>The built-in Places views automatically use a built-in controller, which is an instance of <code>PlacesController</code>, a prototypical JavaScript function defined in {{ Source("browser/components/places/content/controller.js") }}.  So if you use a built-in Places view, you need not write your own controller, worry about hooking up your view to a controller, or really read the rest of this page.  You do, however, need to include <code>PlacesController</code>'s source in your XUL document.  See <a class="internal" href="/en/Displaying_Places_information_using_views#Instantiating" title="En/Displaying Places information using views#Instantiating">Displaying Places information using views</a>.</p><h2>Places commands</h2>
<p>The Places commands are:</p>
<table class="standard-table"> <tbody> <tr> <td><code>placesCmd_new:bookmark</code></td> </tr> <tr> <td><code>placesCmd_new:folder</code></td> </tr> <tr> <td><code>placesCmd_new:livemark</code></td> </tr> <tr> <td><code>placesCmd_new:separator</code></td> </tr> <tr> <td><code>placesCmd_open</code></td> </tr> <tr> <td><code>placesCmd_open:tab</code></td> </tr> <tr> <td><code>placesCmd_open:window</code></td> </tr> <tr> <td><code>placesCmd_reload</code></td> </tr> <tr> <td><code>placesCmd_reloadMicrosummary</code></td> </tr> <tr> <td><code>placesCmd_show:info</code></td> </tr> <tr> <td><code>placesCmd_sortBy:name</code></td> </tr> </tbody>
</table>
<p><code>PlacesController</code> also supports the standard Edit commands:</p>
<table class="standard-table"> <tbody> <tr> <td><code>cmd_copy</code></td> </tr> <tr> <td><code>cmd_cut</code></td> </tr> <tr> <td><code>cmd_delete</code></td> </tr> <tr> <td><code>cmd_paste</code></td> </tr> <tr> <td><code>cmd_redo</code></td> </tr> <tr> <td><code>cmd_selectAll</code></td> </tr> <tr> <td><code>cmd_undo</code></td> </tr> </tbody>
</table>
<h2>Creating custom controllers</h2>
<p>You will need to write your own controller if you want to use commands that <code>PlacesController</code> does not support.  If you are not familiar with controllers, see the <a class="internal" href="/en/XUL_Tutorial/Commands" title="En/XUL Tutorial/Commands">Commands</a> and <a href="/en/XUL_Tutorial/Updating_Commands" title="en/XUL_Tutorial/Updating_Commands">Updating Commands</a> pages in the XUL tutorial.</p>
<p>If your set of commands contains some of those supported by <code>PlacesController</code>, you can use an instance of <code>PlacesController</code> to handle that subset, for example by using a <code>PlacesController</code> instance as a prototype if your controller is a JavaScript object, or by simply passing commands to a <code>PlacesController</code> instance.</p>
Revert to this revision