title: How to access the methods of the controller from another function?
body: <p>So I am making a call to my xsjs using the promise interface of jQuery as follows in my onBeforeRendering method of my Controller named Questionnaire.controller.js which is binded to view Questionnaire.view.xml</p>
  
  <pre><code>onBeforeRendering: function() {jQuery.get("/prototype/OnlineQuestionnaire/getQuestionsAndResponseChoices.xsjs", {
              questionnaireResponseId: jQuery.sap.storage.get("QuestionnaireResponseId"),
              password: jQuery.sap.storage.get("Password")
          }).done(function(data){
       that.OnlineQuestionnaire.controller.Questionnaire.prototype.checkData(); 
  }).fail(function(jqXHR){
              MessageBox.show(jqXHR.responseText, "ERROR", "Service Call Error");
          });
      },
      checkData: function(){console.log("Hi");
      }
  </code></pre>
  
  <p>In my .done() I wanted to access the checkData() method but I was not able to because I donot know how to call the controller's method. I tried various ways : </p>
  
  <pre><code>sap.ui.controller("OnlineQuestionnaire.controller.Questionnaire").checkData();
  </code></pre>
  
  <p>then I tired :</p>
  
  <pre><code>sap.ui.getCore().byId('Questionnaire').getController().checkData();
  </code></pre>
  
  <p>This returned me <code>undefined</code>. So I am still unable to figure out how do I get my controller and then call its method. But I found a workaround and made it work using following, first i defined <code>var that = this;</code> so now my that consists of window object and then I called following':</p>
  
  <pre><code>that.OnlineQuestionnaire.controller.Questionnaire.prototype.checkData();
  </code></pre>
  
  <p>But there should be simplier way and I am missing something out. Can anyone suggest a simplier solution.</p>