How to access the "findById" method of a RESTful service through "getJSON"?

This is the following code of my RESTful service class:

@RequestScoped
@Path("/empresas")
public class EmpresaEndpoint {

    @Inject
    private EmpresaRB empresaRB;

    @GET
    @Path("/{id:[0-9][0-9]*}")
    @Produces("application/json")
    public Response findById(@PathParam("id") final Long id) {
        //TODO: retrieve the empresas
        Empresa empresas = null;
        if (empresas == null) {
            return Response.status(Status.NOT_FOUND).build();
        }
        return Response.ok(empresas).build();
    }

    @GET
    @Produces("application/json")
    public List<Empresa> listAll(
            @QueryParam("start") final Integer startPosition,
            @QueryParam("max") final Integer maxResult) {
        //TODO: retrieve the empresa
        return empresaRB.getEmpresas();
    }

}

If I wanted to access all the data stored on "Empresa" via jQuery, I would do:

$.getJSON( "rest/empresas", function( data ) {
  //whatever is needed.
}

The code above would access the "listAll" method. So how can I access the "findById" method and pass the necessary parameter?

Jon Skeet
people
quotationmark

Well without having used that particular framework, it looks like it's mapping to the right method based on the path - it will use findById if the path has an ID, e.g.

$.getJSON("rest/empresas/100", function(data) {
  // ...
}

(That will find the item with ID 100... obviously substitute the ID of the item you want to find. We don't know where that's coming from, but "rest/empresas/" + id may well be all you need.)

people

See more on this question at Stackoverflow