0
votes

During server side processing, one of the parameters sent from the server "draw" is coming as null, but I am not able to figure out in which scenario is that parameter being sent as null from the server, has anyone encountered this issue before , i tried navigating though the application but I am not able to replicate this issue, got this issue only once, but not able to reproduce it.

Basically, we have a datatable in our application, in which the data gets populated through ajax call, but in one of the scenarious , the "draw" parameter is sent as null from the server.

1
Did you get any error due to this null value?Yuri
Question edited : Actually, the parameter "draw" , is being sent as null value from the server (not while being sent to the server as I mentioned in the question before editing) in one of the scenarios.NEERAJ GUPTA
Our code is not handling the null condition , because of which we are getting datatable error in the UI. Since this is a production issue, we are not allowed to change the code without identifying the issue, we just need to add a null check to fix this issue, my question is that is there any particular scenario in which the "draw" parameter is being sent as null from the server.NEERAJ GUPTA
Can you give some of your codeMohnish Karhade
This is the content of the ftl file(similar to HTML file) which is used server side processing :NEERAJ GUPTA

1 Answers

0
votes
    This is the content of the ftl file(similar to HTML file) which is used server side processing :

"processing": true,
stateSave: true,
"serverSide": true,
"pageLength": 10,
                "lengthMenu": [10, 25, 50, 100],"pagingType": "full_numbers",
                "scrollX": "true","scrollY": 500,
                "ajax": {
                    "url": "/platform/${registry}/facility${facilityId}/case-list/load",
                    "type": 'POST',
                    "data": function (d) {
                        d.visibleColumns = getVisibleColumns();
                    },
                    headers: {
                        'X-CSRF-Token': $('meta[name="_csrf"]').attr('content')
                    }
                },

    There is a code in the same ftl file where the application is manually sending the parameters to the server:
    var url = "/platform/${registry}/facility${facilityId}/case-list/export?output=excel&draw=1&start=0&length=100000";

    Though we are not doing anything with these paramerters in the controller class(Spring MVC contoller)

    This is the code in the java class, which is trying to read this parameter value and parsing it to int , since "req.getParameter("draw")" value is null, its throwing NumberFormatException in the code, but not able to replicate in which scenario.

    public int getDraw() {
        return Integer.parseInt(req.getParameter("draw"));
      }