3

I am working with Datatables 1.10.10. As the size of the dataset is getting large, I find a need to begin using the serverside API provided by Datatables. I have done this before in PHP, but the problem I am having this time is that I need to handle this with Java 8 (in Struts 2 to be more precise).

The API used by DataTables to request the data from the backend is sending query parameters in this format (note some parameters are empty, but they are sent anyway):

draw=1  
columns[0][data]=name  
columns[0][name]=  
columns[0][searchable]=true  
columns[0][orderable]=true  
columns[0][search][value]=  
columns[0][search][regex]=false  
columns[1][data]=binType  
columns[1][name]=  
columns[1][searchable]=true  
columns[1][orderable]=true  
columns[1][search][value]=  
columns[1][search][regex]=false  
columns[2][data]=active  
columns[2][name]=  
columns[2][searchable]=true  
columns[2][orderable]=true  
columns[2][search][value]=  
columns[2][search][regex]=false  
columns[3][data]=notifications  
columns[3][name]=  
columns[3][searchable]=true  
columns[3][orderable]=true  
columns[3][search][value]=  
columns[3][search][regex]=false  
order[0][column]=0  
order[0][dir]=asc  
start=0  
length=10  
search[value]=  
search[regex]=false  
_=1452865138855  

How can I set the jagged, associative array parameters to the Struts 2 Action?

I am looking for a way to handle this in the application layer (as opposed to rewriting the parameters in the server before passing them to the application).

Roman C
  • 49,761
  • 33
  • 66
  • 176
Joe Aldrich
  • 491
  • 4
  • 8
  • Take a look at the duplicate. Submitting json would be a best way to handle it. – Aleksandr M Jan 15 '16 at 16:47
  • What prevents you from doing so, what is the application layer? – Roman C Jan 15 '16 at 17:31
  • 1
    @AleksandrM - That will work, thanks! (sorry, I didn't find the other question earlier - it does appear to be a duplicate of this same problem) – Joe Aldrich Jan 15 '16 at 17:44
  • @RomanC - The application layer is Struts 2 and (as Aleksander M points out in the linked question) it would work if the associative keys were surrounded by single quotes in the parameters, but DataTables 1.10 sends the parameters without the quotes – Joe Aldrich Jan 15 '16 at 17:49
  • @JoeAldrich So, hope this helped you to resolve the issue, especially if you are using Java 8, but I'm not sure if it's related to Java because you didn't write any statement using this language. – Roman C Jan 15 '16 at 17:55
  • @RomanC - Thanks, Struts 2 is a Java MVC framework which I am running on Java 8 / Tomcat 8. I have used Map to receive basic numeric arrays _(e.g. user[5]=john)_ into fields on a Struts Action. I was looking for a way to receive the type of array parameters in the question above. However, it appears the correct solution will be to rewrite the parameters client-side using the technique in the linked question. – Joe Aldrich Jan 15 '16 at 18:06

0 Answers0