I have an issue with the ListGrid Pagination with a RestDataSource.
Given:
This is basically the code for making RestDataSource REST compliant. By default it doesn't use the HTTP-methods, so I had to change the operationBindings. For most of the things this works fine but for paginated listgrid requests it doesn't.
Browsing through the form I saw a post of somebody who has overridden the transformRequest-method, so I gave it a try and I noticed that at that point the DSRequest contains all the information needed for a good pagination request (startRow, etc ...). I didn't change the return, I tried it barely used it for debugging reasons. But the thing is that all the information I have at that point it never reaches my server.
When I look at the request that my server receives I see no parameters at all, besides the one I added myself in the createBinding() method (app=catv_client). The body is also empty, so somewhere between the transformRequest-method and the actual call all the information is lost.
I think the origin of my problems is the fact that I manually set the OperationBindings.
Given:
Code:
private static final Map<String, Object> urlParams = new HashMap<>(); static { urlParams.put("app", "catv_client"); } private static OperationBinding createBinding(final String httpMethod, final DSOperationType operationType) { final DSRequest request = new DSRequest(); request.setHttpMethod(httpMethod); request.setParams(urlParams); request.setWillHandleError(true); final OperationBinding binding = new OperationBinding(); binding.setOperationType(operationType); binding.setDataProtocol(DSProtocol.POSTMESSAGE); binding.setRequestProperties(request); return binding; } public static DataSource createRest(final RestDataSource ds) { ds.setDataFormat(DSDataFormat.JSON); ds.setPrettyPrintJSON(true); final OperationBinding fetch = createBinding("GET", DSOperationType.FETCH); final OperationBinding add = createBinding("POST", DSOperationType.ADD); final OperationBinding update = createBinding("PUT", DSOperationType.UPDATE); // REMOVE PARAMS final OperationBinding remove = createBinding("POST", DSOperationType.REMOVE); String removeUrl = "/DELETE"; if (url != null) { removeUrl = url.replace("?", "/DELETE?"); } ds.setOperationBindings(fetch, add, update, remove); ds.setRemoveDataURL(removeUrl); return ds; }
Browsing through the form I saw a post of somebody who has overridden the transformRequest-method, so I gave it a try and I noticed that at that point the DSRequest contains all the information needed for a good pagination request (startRow, etc ...). I didn't change the return, I tried it barely used it for debugging reasons. But the thing is that all the information I have at that point it never reaches my server.
When I look at the request that my server receives I see no parameters at all, besides the one I added myself in the createBinding() method (app=catv_client). The body is also empty, so somewhere between the transformRequest-method and the actual call all the information is lost.
I think the origin of my problems is the fact that I manually set the OperationBindings.
Comment