0

Im having problem to call my java service when i send an object.

When i send a int parameter for example the service works.

Anyone can help me please

HTML:

<table ng-table="tableParams" class="table table-condensed table-bordered table-striped" show-filter="true">
    <tr ng-repeat="cliente in data">
    <td title="'ID'" filter="{ clienteID: 'number'}" sortable="'clienteID'">
          {{cliente.clienteID}}
    </td>
    <td title="'Nome'" filter="{ primeiroNome: 'text'}" sortable="'primeiroNome'">
          {{cliente.primeiroNome}}
    </td>
    <td title="'Sobrenome'" filter="{ sobrenome: 'text'}" sortable="'sobrenome'">
          {{cliente.sobrenome}}
    </td>
    <td title="'Sexo'" filter="{ sexo: 'text'}" sortable="'sexo'">
          {{cliente.sexo}}
    </td>
    <td><a ng-click="addCliente(cliente)" class="btn btn-small btn-primary">Editar</a></td>
    <td><a ng-click="deleteClienteById(cliente.clienteID)" class="btn btn-small btn-danger">Excluir</a></td>
    </tr>
</table>

CONTROLLER:

angular.module('ProjetoAngularClient').controller('clienteController',
        function($scope, $filter, NgTableParams, clienteService) {

            $scope.addCliente = function(cliente) {
            clienteService.addCliente(cliente)
        };
});

SERVICE JS:

factory.addCliente = function(cliente) {
  return $http({
            method : 'POST',
            url : '/ProjetoAngular/cliente/addCliente',
            header : {
            'Content-Type': 'application/json' 
            }
          });
};

JAVA SERVICE:

@POST
@Path("/addCliente")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void addCliente(Cliente cliente) {
     ClienteDAOImpl dao = new ClienteDAOImpl();
     dao.addCliente(cliente);
}
ojus kulkarni
  • 1,877
  • 3
  • 25
  • 41

0 Answers0