title: Routing in SAPUI5: How to implement passing of URL? Model data not initialy loaded
body: <p>My goal is to write a SAPUI5 Fiori app with routing support. One mail goal is to have passable URLs. For example in an E-Mail like "please approve this: <em>link</em>". The <em>link</em> is an URL matched by my rounting config, e.g.<code>index.html#/applicants/8</code>.</p>
  
  <p>I use a typical sap.m.SplitApp kind of application. Clicking a list item in masterview changes the URL to <code>index.html#/applicants/[id of entry in JSON]</code>. I can click on the list, my defined routes are getting matched and the apps loads the (applicant) data as expected.</p>
  
  <p>However, and here comes my question, this doeas not work when using an URL directly, say pasting <code>[my url]/index.html#/applicants/8</code> into my browser. The app is launched but no detail data is loaded. I have to click on another list item again to get the data. </p>
  
  <p>Actually, the controller is called when passing the URL, but it seems the model is not initiated and undefined. My JSON model is bound in the <code>createContent</code> function of my <code>Component.js</code></p>
  
  <p>// Update 2015-05-14
  The problems seems to be around the <code>getData()</code> function. I have the model, it has the entries, but <code>getData()</code> returns undefined for the first time my app is loaded. I recently read <code>getData()</code> is deprecated. How should I improve my coding below?</p>
  
  <pre><code>// Component.js
  ui5testing.Component.prototype.createContent = function(){
    // create root view
    var oView = sap.ui.view({
      id : "app",
      viewName : "ui5testing.view.Main",
      type : "JS",
      viewData : {
          component : this
      }
    var oModel = new sap.ui.model.json.JSONModel("model/mock_applicants.json");
    oView.setModel(oModel);
    [...]
    return oView;
  });
  // Master controller
  handleApplicantSelect : function (evt) {
      var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
      var context  = evt.getParameter("listItem").getBindingContext();
      var path = context.getPath();
      var model = this.getView().getModel();
      var item =  model.getProperty(path);
      oHashChanger.setHash("applicants/" + item.id);
  },
  
  // Detail controller
  onInit: function() {
      this.router = sap.ui.core.UIComponent.getRouterFor(this);
      this.router.attachRoutePatternMatched(this._handleRouteMatched, this);
  },
  
  _handleRouteMatched : function(evt){        
      var objectId = evt.getParameter("arguments").id;
      var model = this.getView().getModel();
      var data = model.getData()["applicants"];
      var pathId;
  
      if (data) {
          for (var i = 0; data.length; i++) {
              if ( objectId == data[i].id ) {
                  pathId = i;
                  break;
              }
          }
  
          var sPath = "/applicants/" + pathId;
  
          var context = new sap.ui.model.Context(model, sPath)
          this.getView().setBindingContext(context);              
      }
  },
  </code></pre>