Using configuration data to make the installer reusable

Mark Birbeck's picture

To make it easy to reuse this installer form for other bars, we'll put all information that is specific to our del.icio.us side-bar into an external XML document. Create a document called delicious-sidebar.xml that contains the following:

<bar retval="0">
  <type>2</type>
  <screenshot>http://static.flickr.com/142/319487219_f598c70667.jpg</screenshot>
  <internalName>fpdelicioussidebar</internalName>
  <name>del.icio.us Sidebar</name>
  <description>
    The del.icio.us Sidebar allows you to quickly add a bookmark to del.icio.us
    for a document that you are viewing in the main browser window.
  </description>
  <uri>http://svn.x-port.net/svn/public/samples/del.icio.us/howto.html</uri>
</bar>

type, internalName, name and uri correspond to the parameters needed by sb:GenerateBar, whilst screenshot and description are used in the form, as we'll see in a moment.

To make the configuration parameters available to the form, we need to load it into an instance, so next add the following mark-up to the model:

    <xf:model id="m-soft-bars" functions="sb:GenerateBar sb:RemoveBar">
      <xf:instance src="delicious-sidebar.xml" />
    </xf:model>