Question 


Loading Data From A Data Suitcase (MOJO)


Answer 


There are times when you want to pre-load data from a web service. In this example we are using a Data Suitcase or (MOJO) Journey Objects which is stored on the server.

Firstly we have an interaction which uploads the Data Suitcase which contains

a list of the top V8 super car drivers and information.

$t->fetch('http://www.v8supercars.com.au/ajax.aspx?feed=TeamDrivers&seriesid=1&seasonid=11');
$t->setJourneyObject('V8s', $t->result);
return('MoJo Uploaded Successfully');

We then create another interaction with is type "xslt" and server based/ The Mojo XML needs to point to the data suitcase "V8s" which was saved in the first interaction. The mojo xml is

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[http://www.w3.org/1999/XSL/Transform">]

<xsl:template match="/">
  <div>
    <h1>Drivers List</h1>
  </div>
  <table>
    <tr>
      <th></th>
      <th>id</th>
      <th>Name</th>
      <th>Best Bathurst Result</th>
      <th></th>
    </tr>
    <xsl:apply-templates select="/Drivers/Driver">
    </xsl:apply-templates>
  </table>
</xsl:template>

<xsl:template match="Driver">
  <tr>
    <td>
      <span
          class="blink-starrable"
          data-type="V8s"
          data-id="{DriverID}">
      </span>
    </td>
    <td><xsl:value-of select="DriverID" /></td>
    <td><xsl:value-of select="Name" /></td>
    <td><xsl:value-of select="BestBathurstResult" /></td>
    <td><a interaction="V8_SUPERCARS_DRIVER EDIT" mojo="V8s" xpath="//Driver[DriverID={DriverID}]">Edit</a></td>
   </tr>
</xsl:template>

</xsl:stylesheet>

You will need a BlinkForm built with the matching the fields in the xml and the call to the interaction in this case "V8_SUPERCARS_DRIVER EDIT".