Vaadin grid lazy loading from external WEB API

Hi there:

I have a an external web API which returns a Page

@GetMapping(“/paged”)
public Page getpagedplotinformationview(Pageable pageable)
{
return _plotinformationview_repository.findAll(pageable);
}

Postman shows that the method works okay. Now…I have a frontend application that uses Vaadim grid to show the data. The unpaged data is retrieved without an issue, the problem is when I want to use the above method in the client side using the code below:

public List Pagedlist(Pageable pageable) {
return webClient.get()
.uri(uriBuilder → uriBuilder
.path(“api/paged”)
.build())
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.toEntityList(plotinformationview.class)
.block().getBody();

The java class for the UI grid tries to populate the grid by calling the controller method as below:
grid.setItems(query → _plotinformationviewservices.Pagedlist(VaadinSpringDataHelpers.toSpringPageRequest(query)).stream())

I also tried
grid.setItemsPageable(query → _plotinformationviewservices.Pagedlist(query));

when I run the application, the debugger doesn’t throw any error and the browser Developer tools shows that the the WEB API is hit and returns a 200 HTTP response, however instead of appearing all the data in the vaadim grid the only thing that appears is a zero (0).
Obviously, I’m not doing something right but I don’t know what it is, the Pageable in the web api has default values in case that the pagesize and pagenumber parameters aren’t provided . I run the test in postman and yes…there is always data returned even if the query parameters aren’t provided by the frontend.
I read numerous articles about dataprovider and callbacks but I’m failing to understand as I haven’t come across with one simple example.

Any assistance will be gratly appreciated

Thanking you in advance.

Regards

Jose

Have you deubugged to see if the method returns data?

1 Like

Hi Simon:

Thanks for your assistance thus far. The response from the server is empty instead of receiving this

{
“key”: “1”,
“col0”: “11812”,
“col1”: “1 Omar Rd”,
“col2”: “85”,
“col3”: “Cornelius Noel Christopher”,
“col4”: “Lewis”,
“col5”: “”,
“col6”: “1976-12-24”
},

I receive

{
“key”: “1”,
“col0”: “0”,
“col1”: “”,
“col2”: “”,
“col3”: “”,
“col4”: “”,
“col5”: “”,
“col6”: “”
}

Meaning that although the server is hit ( HTTP 200), no data is return. As previously said, I’m not sure whether the way I’m calling the WEB REST API is the correct one
Any ideas?

So your Vaadin is fine and working. Your server sends garbage and the garbage is shown properly. So fix the server or fix the data the server is reading.