I want to add some REST-Modifications to my current vaadin project. Therefore I have implemented following code so far:
// calls findByName Method in the RestClient.class
List<Customer> customers = restClient.findByName(firstName.getValue(), lastName.getValue());
/* RestClient-class */
public List<Customer> findByName(String firstname,String lastname) {
List<Customer>customerList = webtarget.path("server").
path("restserver").
path("findByName").
queryParam("firstname", firstname).
queryParam("lastname", lastname).
request().
accept(MediaType.TEXT_PLAIN). // Do I need this?
get(Customer.class); // How to cast here?
return customerList;
}
/* Server class - handling requests */
@GET
@Path("/findByName")
@Produces(MediaType.TEXT_PLAIN)
public List<Customer>findByName(@QueryParam("firstname")String firstname,@QueryParam("lastname")String lastname) throws ClassNotFoundException, SQLException {
System.out.println("findByName in Server aufgerufen");
customerService = new CustomerService();
return customerService.findByName(firstname, lastname);
}
My code is not working. I receive HTTP Status 500. I put some comments into the code section. Could you help me to answer these please?
Thanks!!
Best regards,
Nazar Medeiros