Search Posts

Category: java

Best way to handle multiple async calls and scope updates in AngularJS

I’m facing a difficult situation where I have to filter out search results based on various filters on UI. Whenever I make a search, there is an api call which loads the results asynchronously. User can filter any number of times even before the results of previous search criteria loads. httpService.get(“getCREWRequests.do”, filters.getValues()).then(function(data){ $scope.requests=data; }); I’m simply updating my scope with different results from api and showing them on screen. However, api calls being asynchronous, the […]

AngularJS fails to find REST api

I’m trying to connect my angular to my API but my Angular will not find the path to mu API and I can’t see why it it cant find it.. controllerJS.js /* global angular */ angular.module(‘myApp’, [‘ngRoute’, ‘ngResource’]) .controller(‘AppLoginCtrl’, [“$resource”, “$scope”, function ($resource, $scope) { var apiBase = “/api”; var RegisterUser = $resource(“/api/createUser”, {}, {save: {method: ‘POST’, responseType: ‘json’}}); var Login = $resource(“/api/login”, {}); $scope.succes = “Welcome back.”; $scope.acceptUser = false; //Register form $scope.username = […]

Text file is remaining opened through UI

I have written the java code to udpate the folder name and text file inside that folder. when i hit the rest call through postman then it works properly. I have used only 2 objects inside my method (BufferReader and FileReader). Also I am using JGIT code for committing changes. I have used Git class for same. I have closed same object also. Through postman its working very well. I have used angular JS to […]

Upload file from angularjs to spark-java, throws "No Content for Multipart Request"

My Current Setup Server Side <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> <version>9.3.6.v20151106</version> </dependency> <dependency> <groupId>com.sparkjava</groupId> <artifactId>spark-core</artifactId> <version>2.3</version> </dependency> I am trying to upload a file from AngularJS to my server, But it is throwing ‘No content for Multipart Request’ <form name=”upload” class=”form”> <input type=”file” name=”myImage” id=”myImage” accept=”image/*” onchange=”angular.element(this).scope().attachedImage(this)”/> </form> My Controller $scope.attachedImage = function (element) { $scope.$apply(function ($scope) { $scope.myImage = element.files[0]; }); console.log(‘Image Attached’); }; function uploadFile() { var fd = new FormData(); fd.append(“myImage”, $scope.myImage); var service […]

Angularjs and Java – Different hours between timezones

My web application uses in front end bootstrap 3.3.7, ui-bootstrap-tpls-2.0.1 and angular 1.5.8. In back end Java 8, tomcat 8 and provide JSON rest services. The TimeZone in server is America/Sao_Paulo, in frond end is America/Bahia. The Html for input date uses uib-datepicker-popup=”dd/MM/yyyy” For input time uses <div uib-timepicker ng-model=”model.jogo.data” hour-step=”1″ minute-step=”1″ show-meridian=”false”> </div> No date parse occurs on the server. The piece of the angular controller code that gets json from server is: var […]

Live interaction between Frontend and backend

I’m busy making a controller website where I switch relays on and off. My switching has a schedule on so it can be activated without human interaction. my question is how can I do a live update on my HTML frontend, if the scheduler activates a switch, to show the user the switch is active without needing to refresh the page? I have a basic spring boot application with tomcat angularjs and thymeleaf Source: AngularJS

How to attach request params in spring which is retrieved from front end?

I tried this code below…can anyone kindly help me how to pass the params to the spring method and is it a correct implementation in angularjs. @GetMapping(“/extended-registered-time”) public ResponseEntity<List<Registered_time>> getSubLeaves(@ApiParam Pageable pageable) { log.debug(“REST request to get registered time : {}”, pageable); LocalDate startDate = LocalDate.of(2018,01,15); LocalDate endDate = LocalDate.of(2018,01,24); List<Registered_time> result = ExtendedRegisteredTimeService. getSelectedRegisteredTime(startDate,endDate); return new ResponseEntity<>(result, HttpStatus.OK); } This is the frontend implementation(AngularJs) .factory(‘RegisteredTimeService’, RegisteredTimeService); RegisteredTimeService.$inject = [‘$resource’]; function RegisteredTimeService ($resource) { var […]

Spring Boot CSRF fails when handled by Load balancer

I have implemented CSRF filter in spring boot by using header based token method. When I run on single server my applications works well, when I introduce another server or request that serverd by load balancer (depends on how load balancer serves request) it fails to validate the token given by the other server. Can anyone here tell me that how can we create token for CSRF based on particular key which will be same […]

Next Page »