title: Make ExtJS singleton return object using Ext.Ajax.request
body: <p>Well, I am very new to javascript and for sure, I am very new at extJS, which is a Sencha JS framework. What I want to do I think is very simple, but I do not know to much about js.</p>
  
  <p>This is the js file I've been provided:</p>
  
  <pre><code>Ext.define('app.util.UserWGroupInfo', {
      alternateClassName: ['UserInfo', 'WGroupInfo'],
      singleton: true,
  
      /**
       * Default information to be shown / displayed
       */
      statics: {
          userData: {
              'username':                 'User Name',
              'phoneNumber':              'Phone',
              'firstName':                'First Name',
              'lastName':                 'Last Name',
              'emailAddress':             'Email',
              'address.addressLine1':     'Address',
              'address.city':             'City',
              'address.stateOrProv':      'State'
          },
          wGroupData: {
              'name':                     'Name',
              'type':                     'Type',
              'description':              'Description',
              'phoneNumber':              'Phone',
              'poc':                      'POC'
          }
      },
  
      /**
       * Holder for the data to display
       * @type {Object}
       */
      dataToDisplay: {
  
      },
  
      /**
       * display a popup on no data retrieved
       * @type {Boolean} [true]
       */
      displayMsg: true,
  
      /**
       * Gets data of an user from the server
       * 
       * @param {String} userInfo, consider passing "usid:name"
       * @param {Boolean} double set true to check Like User&amp;WGroup
       */
      getUserInfo: function(userInfo, displayMsg) {
  
          if (Ext.isEmpty(userInfo)) {
              return;
          }
  
          userInfo = userInfo.split(':');
          var user = userInfo[0] + ':' + + userInfo[1];
  
          //Note: to retrieve tooltip, set defaults data
          this.dataToDisplay = this.statics().userData;
          this.typeSearch = "User";
  
          if (displayMsg) {
              this.displayMsg = displayMsg;
          }
  
          this.getSysAdminObj('users', user);
      },
  
      /**
       * Gets data of a workgroup from the server
       * 
       * @param {String} wGroupInfo, consider passing "wgid:name"
       * @param {Boolean} double set true to check Like User&amp;WGroup
       */
      getWGroupInfo: function(wGroupInfo, displayMsg) {
  
          if (Ext.isEmpty(wGroupInfo)) {
              return;
          }
  
          wGroupInfo = wGroupInfo.split(':');
          var wGroup = wGroupInfo[0] + ':' + wGroupInfo[1];
  
          //Note: to retrieve tooltip, set default data
          this.dataToDisplay = this.statics().wGroupData;
          this.typeSearch = "Work Group";
  
          if (displayMsg) {
              this.displayMsg = displayMsg;
          }
  
          this.getSysAdminObj('workgroups', wGroup);
      },
  
      getDataInfo: function() {
          return this.dataInfo;
      },
  
      /**
       * Retrieve a SysAdmin object to perform a connection to the server side.
       * 
       * @param {String} type. Consider as possible values: "users" or "workgroups"
       * @param {String} info
       */    
      getSysAdminObj: function(type, info) {
          var me = this;
  
          Ext.Ajax.request ({
              url:        '../rest/sysadmin/' + type + '/' + info,
              method:     'GET',
              scope:      me,
              async:      false,
              callback:   me.storeInfo
          });
      },
  
      /**
       * Map information retrieved to the dataInfo object.
       * 
       * Before storing the data, it is necessary to check if the search should be executed as user or workgroup.
       */
      storeInfo: function(o, s, r) {
          if ( !s ) {
              if (this.displayMsg) {
                  Logger.notify('User Info Loading', 'Failed to load extra user info');
              }
              this.errorResponse = true;
              return;
          };
  
          this.errorResponse = false;
          var obtainedData = XmlConverter.unmarshal(r);
          this.dataInfo = obtainedData;
      }
  
  });
  </code></pre>
  
  <p>I've been provided with this class, which is a singleton, what it does? It retrieves user information and workgroup information based on call made to a REST service (Java), I use a "SysAdminObject" which is a "js" which handles some behaviors of the connection, and finally, I use a "Ext.Ajax.request" to get the data from server. When I execute the callback I can see the function "storeInfo" which sets the data into a variable (well, that's what it seems to be doing). Then I can handle the dataInfo variable which contains all the information I need and I return it with method:"getDataInfo". Is there any way to just return the data directly whenever you call the service? I mean in java, for example:</p>
  
  <pre><code>public Object getUserInfo() {
    Object obj = null;
    obj = getFromServer();
    return obj;
  }
  </code></pre>
  
  <p>Is there any way to have this behavior with extJS and Javascript?</p>
  
  <p>Thanks in advance for your time and help. I really appreciate it.</p>