title: AngularJS: A slow java method is not being called from user interface
body: <p><strong>My setup:</strong></p>
  
  <p>I want to call a java method which accepts a string from UI and returns a JSON String. This method takes 5+ seconds to compute and return the JSON String. This method is not even being called when I use UI to enter as argument: I confirmed this as some files are created locally which are not being created.</p>
  
  <p><strong>The Setter method:</strong></p>
  
  <pre><code>public void setBrand(String brand) {
  this.brand  = AmazonReview.getAmazonReview(this.brand);
    }
  </code></pre>
  
  <p><strong>The slow method:</strong></p>
  
  <pre><code>public static String getAmazonReview(String s){
  ...;
  Process p1 = Runtime.getRuntime().exec("./something.pl com " + id);
  ...;
  JSONObject obj = new JSONObject();
  obj.put("product1", l1);
  return obj.toJSONString();
  }
  </code></pre>
  
  <p><strong>The Getter method:</strong></p>
  
  <pre><code>public String getBrand() {
      return brand;
    }
  </code></pre>
  
  <p><strong>UI Code</strong></p>
  
  <pre><code>angular.module("sprang", ["sprang.services"]).
      config(function ($routeProvider) {
          $routeProvider
              .when('/brands', {templateUrl: '/views/brands/list.html', controller: BrandListController})
              .when('/brands/:brandId', {templateUrl: '/views/brands/detail.html', controller: BrandDetailController});
      });
  
  function BrandListController($scope, Brand) {
          $scope.brands = Brand.query();
          $scope.deleteBrand = function(brand) {
              brand.$delete(function() {
                  $scope.brands.splice($scope.brands.indexOf(brand),1);
                  toastr.success("Deleted");
              });
          }
      }
  
  function BrandDetailController($scope, $routeParams, $location, Brand) {
          var brandId = $routeParams.brandId;
          if (brandId === 'new') {
              $scope.brand = new Brand();
          } else {
              $scope.brand = Brand.get({brandId: brandId});
          }
          $scope.save = function () {
              if ($scope.brand.isNew()) {
                  $scope.brand.$save(function (brand, headers) {
                      toastr.success("Created");
                      var location = headers('Location');
                      var id = location.substring(location.lastIndexOf('/') + 1);
                      $location.path('/brands/' + id);
                  });
              } else {
                  $scope.brand.$update(function() {
                      toastr.success("Updated");
                  });
              }
          };
      }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>If I replace the method code with just <code>return "Hello";</code> my UI is displaying <code>Hello</code>.
  My project is setup with AngularJS with Spring which is working fine end to end.
  I tried to make the method save the json locally so UI is nomore obliged to display the output, still method is not even called.
  How can I proceed further? Thanks in advance.</p>
  
  <p>In simple words, When I call my slow java method in eclipse, I get the expected JSON but when I do the same with UI (AngularJS), the method is not being called.</p>