Hi,
My backend is working and tested with POSTMAN. My Angular front end is very
close but the last bit I need to get working eludes me. Basically I serve
up some data and want to persist when the checkbox is ticked/unticked via a
PUT call. Right now, data is returned and displayed but no update is
occuring when checkbox is toggled.
In addition, Intellij is not hitting my debug points so I don't know whats
going wrong. Here is applicable code
CustomChq.tpl.html
<div class="row">
<div class="form-group">
<input type="text" class="form-control" ng-model="zz"
placeholder="Vendors FYBCHKS_VEND_FULL_NAME"/>
</div>
<table class="table table-striped">
<th>Banner Invoice Number</th>
<th>Vendor Name</th>
<th>Vendor Invoice #</th>
<th>Status</th>
<th>Currency</th>
<th>Net Amount</th>
<th>Pay Invoice ?</th>
<tr ng-repeat="fybchks in fybchkss | filter:zz">
<td>{{fybchks.fybchks_INVH_CODE}}</td>
<td>{{fybchks.fybchks_VEND_FULL_NAME}}</td>
<td>{{fybchks.fybchks_VEND_INV}}</td>
<td>{{fybchks.fybchks_DESCRIPTION}}</td>
<td>{{fybchks.fybchks_CURR_CODE}}</td>
<td>{{fybchks.fybchks_NET_AMT}}</td>
<!-- <td><input type="radio" ng-checked="fybchks.SelectChq"></td>
-->
<!--
<td> <input type="radio" name="SelectChq"
data-ng-model="fybchks.SelectChq" data-ng-value="true" />
{{fybchks.SelectChq}} </td>
<td> <input type="checkbox" ng-model="fybchks.fybchks_PRINTCHQ"
ng-true-value="1" ng-false-value="0"> </td> -->
<td> <input type="checkbox" ng-click="update(fybchks)"
ng-model="fybchks.fybchks_PRINTCHQ" ng-true-value="1" ng-false-value="0"> </td>
</tr>
</table>
</div>
I also tried ng-change on checkbox
CustomChq.js
angular.module( 'ngBoilerplate.CustomChq', [
'ui.router',
'plusOne',
'ngBoilerplate.account'
])
/**
* Each section or module of the site can also have its own routes. AngularJS
* will handle ensuring they are all available at run-time, but splitting it
* this way makes each module more "self-contained".
*/
// .config(function config( $stateProvider ) {
.config(function config( $stateProvider,$resourceProvider ) {
//ADDED below line with $resourceProvider above on Sept 8, 2016 to try
to solve missing PUT syntax
$resourceProvider.defaults.actions.update = { method: 'PUT' };
$stateProvider.state( 'CustomChq', {
url: '/CustomChq',
views: {
"main": {
templateUrl: 'CustomChq/CustomChq.tpl.html',
controller: 'CustomChqCtrl'
}
},
data:{ pageTitle: 'Create Custom Cheque Batch' },
resolve:{
fybchkss: function (fybchksService) {
return fybchksService.getAllFybchkss();
}
}
});
})
.factory('fybchksService', function ($resource) {
var service = {};
//$resourceProvider.defaults.actions.update = {method: 'PUT'};
service.update = function (fybchks, success, failure) {
var Fybchks =
$resource("/BannerChqSelection/rest/fybchks/{FYBCHKS_INVH_CODE}");
Fybchks.save({}, fybchks,success,failure);
};
service.getAllFybchkss = function() {
var Fybchks = $resource("/BannerChqSelection/rest/fybchks");
return Fybchks.get().$promise.then(function(data) {
return data.fybchkss;
});
};
return service;
})
/**
* And of course we define a controller for our route.
*/
.controller("CustomChqCtrl", function ($scope, fybchkss) {
$scope.fybchkss = fybchkss;
$scope.update = function () {
fybchkss.update();
};
})
;
FYBCHKSController.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import tutorial.core.models.BannerEntities.FYBCHKS;
import tutorial.core.services.exceptions.FYBCHKSExistsException;
import tutorial.core.services.FYBCHKSService;
import tutorial.core.services.util.FYBCHKSList;
import tutorial.rest.exceptions.ConflictException;
import tutorial.rest.resources.FYBCHKSListResource;
import tutorial.rest.resources.FYBCHKSResource;
import tutorial.rest.resources.asm.FYBCHKSListResourceAsm;
import tutorial.rest.resources.asm.FYBCHKSResourceAsm;
import java.net.URI;
/**
* Created by finwebmailer on 6/7/2016.
*/
@Controller
@RequestMapping("/rest/fybchks")
public class FYBCHKSController {
private FYBCHKSService fybchksService;
@Autowired
public FYBCHKSController(FYBCHKSService fybchksService)
{
this.fybchksService = fybchksService;
}
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<FYBCHKSListResource> findAllFYBCHKSs()
{
FYBCHKSList fybchksList = fybchksService.findAllFYBCHKSs();
FYBCHKSListResource fybchksListRes = new
FYBCHKSListResourceAsm().toResource(fybchksList);
return new ResponseEntity<FYBCHKSListResource>(fybchksListRes,
HttpStatus.OK);
}
@RequestMapping(value="/{FYBCHKS_INVH_CODE}",
method = RequestMethod.GET)
public ResponseEntity<FYBCHKSResource> getFYBCHKS(@PathVariable String
FYBCHKS_INVH_CODE)
{
FYBCHKS fybchks = fybchksService.findFYBCHKS(FYBCHKS_INVH_CODE);
if(fybchks != null)
{
FYBCHKSResource res = new FYBCHKSResourceAsm().toResource(fybchks);
return new ResponseEntity<FYBCHKSResource>(res, HttpStatus.OK);
} else {
return new ResponseEntity<FYBCHKSResource>(HttpStatus.NOT_FOUND);
}
}
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<FYBCHKSResource> createFYBCHKS(
@RequestBody FYBCHKSResource sentFYBCHKS
) {
try {
FYBCHKS createdFYBCHKS =
fybchksService.createFYBCHKS(sentFYBCHKS.toFYBCHKS());
FYBCHKSResource res = new
FYBCHKSResourceAsm().toResource(createdFYBCHKS);
HttpHeaders headers = new HttpHeaders();
headers.setLocation(URI.create(res.getLink("self").getHref()));
return new ResponseEntity<FYBCHKSResource>(res, headers,
HttpStatus.CREATED);
} catch(FYBCHKSExistsException exception) {
throw new ConflictException(exception);
}
}
@RequestMapping(value="/{FYBCHKS_INVH_CODE}",
method = RequestMethod.DELETE)
public ResponseEntity<FYBCHKSResource> deleteFYBCHKS(
@PathVariable String FYBCHKS_INVH_CODE) {
FYBCHKS fybchks = fybchksService.deleteFYBCHKS(FYBCHKS_INVH_CODE);
if(fybchks != null)
{
FYBCHKSResource res = new FYBCHKSResourceAsm().toResource(fybchks);
return new ResponseEntity<FYBCHKSResource>(res, HttpStatus.OK);
} else {
return new ResponseEntity<FYBCHKSResource>(HttpStatus.NOT_FOUND);
}
}
@RequestMapping(value="/{FYBCHKS_INVH_CODE}",
method = RequestMethod.PUT)
public ResponseEntity<FYBCHKSResource> updateFYBCHKS(
@PathVariable String FYBCHKS_INVH_CODE, @RequestBody
FYBCHKSResource sentFYBCHKS) {
FYBCHKS updatedEntry = fybchksService.updateFYBCHKS(FYBCHKS_INVH_CODE,
sentFYBCHKS.toFYBCHKS());
if(updatedEntry != null)
{
FYBCHKSResource res = new
FYBCHKSResourceAsm().toResource(updatedEntry);
return new ResponseEntity<FYBCHKSResource>(res, HttpStatus.OK);
} else {
return new ResponseEntity<FYBCHKSResource>(HttpStatus.NOT_FOUND);
}
}
@RequestMapping(value="/callMethod1/{FYBCHKS_INVH_CODE}",
method = RequestMethod.POST)
public ResponseEntity<FYBCHKSResource> callTestAPI(
@PathVariable String FYBCHKS_INVH_CODE) {
//fybchksService.deleteFYBCHKS(FYBCHKS_INVH_CODE);
fybchksService.callTestAPI(FYBCHKS_INVH_CODE);
return new ResponseEntity<FYBCHKSResource>(HttpStatus.OK);
/*
if(fybchks != null)
{
FYBCHKSResource res = new FYBCHKSResourceAsm().toResource(fybchks);
return new ResponseEntity<FYBCHKSResource>(res, HttpStatus.OK);
} else {
return new ResponseEntity<FYBCHKSResource>(HttpStatus.NOT_FOUND);
} */
}
@RequestMapping(value="/callMethod2",
method = RequestMethod.POST)
public ResponseEntity<FYBCHKSListResource> ValidateFYBCHKS()
{
FYBCHKSList fybchksList = fybchksService.ValidateFYBCHKS();
FYBCHKSListResource fybchksListRes = new
FYBCHKSListResourceAsm().toResource(fybchksList);
return new ResponseEntity<FYBCHKSListResource>(fybchksListRes,
HttpStatus.OK);
}
}
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.