I have a case where user can select specific entities with checkbox to be deleted. When user selects specific entity it's id is added to a specific array. For example if I would select first, second and fourth entities their id's would be:
[0, 1, 3]
In front-end service I use following method:
deleteEntities: function(batchIds){
return $http.delete('/finance/entities', {params: [batchIds collection here??]}).success(function(data){
return data;
});
}
I would pass this data to back-end service. Which uses following method:
@Component
@Path("/entities")
@Produces("application/json")
public class FinanceEntityServiceImpl implements FinanceEntityService {
@DELETE
public void massDeleteEntitiesByIds(String batchIds){
System.out.println("batch ids: " + batchIds);
List<Long> idList = GsonProcessing.deserializeIdsList(batchIds);
financeDao.massDelete(idList);
}
}
When I run above code
I have been searching on the net quiet while on how to delete collection resource with angularjs $http and I haven't found yet.
I'm also not sure whether I'm able to put fresh collection to $http.delete
as parameter where it says [batchIds collection here??].
What I know this far about deleting collection is that the url should be in form of '/myURL/batch?id=1&id=2&id=3'
and correct me if I'm wrong. The problem here is that what if I want to delete a batch of 20 ids, it doesn't make any sense to put all id's in same url.
So my question is what is best way and how to delete collection resources using angularjs $http.delete?