title: Best practice to lazy load data on tab click
body: <p>Within the onBeforeRendering() function of a view how should I determine if a specific node is present in the model and modify the model to include the node if not? This question is about lazy loading of data to the model for data that will be infrequently accessed by users but would have a performance penalty if loaded with initial model data.</p>
  
  <p>My use case has a list page leading to a detail page for whatever item in the list the use clicks. On the detail page is a set of tabs which expose sub-details related to the selected detail. Specifically a long text description of a the brief for a task.</p>
  
  <p>The tab control leads via manifest.json style routing to display a view in the tabs content area.</p>
  
  <p>This is my current working code which is within the onBeforeRendering event of the view controller:</p>
  
  <pre><code>onBeforeRendering: function(oEvent){
  
  var sPath = this.getView().getBindingContext("Projects").getPath(); // something like /task/6
  console.log('Path='+sPath)
  
  var oModel = this.getView().getModel("Projects");   
  var oTask = oModel.getProperty(sPath + "/brief");
  if (oTask) { // looks like /brief exists so must already have loaded the brief
      // nothing to do
      console.log('Use existing data')
  }
  else { //  /brief not yet present so we need to load it up
      console.log('Load new data')
      oModel.setProperty(sPath + "/brief", "This is the brief...") // replace with loaddata() from server, use attachRequestCompleted to call function to modify model.
  }}
  </code></pre>
  
  <p>Question - is this the correct approach?</p>
  
  <p>Edit: Based on discussion in <a href="https://stackoverflow.com/questions/40258071/lazy-loading-data-after-initial-load">this question</a> I modified my code to use an event that fires per display of the view. onBeforeRendering turned out to run without much apparent predictability - which I am sure it has but in any case I wanted a one-per-display event. Also, I fleshed out the code further but retained the basic structure and it appears to do what I wanted.</p>