Search code examples
exceptionextjs4put

How can I prevent ExtJS 4.2.1 from processing the totalProperty on a PUT request?


We are using ExtJS 4.2.1 and Spring MVC / Data-Rest. Anyway, the data-rest will return the following structure on a successful GET request:

{
    content: [ ... objects .... ],
    links: [ ... list of rel links ... ],
    page: {
        size: 25,
        totalElements: 4,
        totalPages: 1,
        number: 1
    }
}

So, in my proxies, I have set the totalProperty to page.totalElements. Works great.

However, when we send a PUT request, the natural (and correct, I believe) response is to send a 204 NO CONTENT. Now, if our totalProperty were set to something like total (not page.xxx) then it's fine. But ExtJS is trying to parse the page.totalElements and returning an exception because page is null.

So how can I tell ExtJS to ignore the totalProperty on a PUT request?


Solution

  • Ha. Looks like I found a work-around. Not sure if I like it but it works. I changed my controller as such:

    return new ResponseEntity<>("OK", HttpStatus.OK);
    

    Where as before, it was:

    return new ResponseEntity(HttpStatus.OK);
    

    ExtJS seems to not mind that. Strange.