1 | package jquery.datatables.controller;
|
---|
2 |
|
---|
3 | import javax.servlet.http.HttpServletRequest;
|
---|
4 |
|
---|
5 | public class DataTablesParamUtility {
|
---|
6 |
|
---|
7 | public static DataTableRequestParam getParam(HttpServletRequest request)
|
---|
8 | {
|
---|
9 | if(request.getParameter("sEcho")!=null && request.getParameter("sEcho")!= "")
|
---|
10 | {
|
---|
11 | DataTableRequestParam param = new DataTableRequestParam();
|
---|
12 | param.sEcho = request.getParameter("sEcho");
|
---|
13 | param.sSearchKeyword = request.getParameter("sSearch");
|
---|
14 | param.bRegexKeyword = Boolean.parseBoolean(request.getParameter("bRegex"));
|
---|
15 | param.sColumns = request.getParameter("sColumns");
|
---|
16 | param.iDisplayStart = Integer.parseInt( request.getParameter("iDisplayStart") );
|
---|
17 | param.iDisplayLength = Integer.parseInt( request.getParameter("iDisplayLength") );
|
---|
18 | param.iColumns = Integer.parseInt( request.getParameter("iColumns") );
|
---|
19 | param.sSearch = new String[param.iColumns];
|
---|
20 | param.bSearchable = new boolean[param.iColumns];
|
---|
21 | param.bSortable = new boolean[param.iColumns];
|
---|
22 | param.bRegex = new boolean[param.iColumns];
|
---|
23 | for(int i=0; i<param.iColumns; i++){
|
---|
24 | param.sSearch[i] = request.getParameter("sSearch_"+i);
|
---|
25 | param.bSearchable[i] = Boolean.parseBoolean(request.getParameter("bSearchable_"+i));
|
---|
26 | param.bSortable[i] = Boolean.parseBoolean(request.getParameter("bSortable_"+i));
|
---|
27 | param.bRegex[i] = Boolean.parseBoolean(request.getParameter("bRegex_"+i));
|
---|
28 | }
|
---|
29 |
|
---|
30 | param.iSortingCols = Integer.parseInt( request.getParameter("iSortingCols") );
|
---|
31 | param.sSortDir = new String[param.iSortingCols];
|
---|
32 | param.iSortCol = new int[param.iSortingCols];
|
---|
33 | for(int i=0; i<param.iSortingCols; i++){
|
---|
34 | param.sSortDir[i] = request.getParameter("sSortDir_"+i);
|
---|
35 | param.iSortCol[i] = Integer.parseInt(request.getParameter("iSortCol_"+i));
|
---|
36 | }
|
---|
37 | return param;
|
---|
38 | }else
|
---|
39 | return null;
|
---|
40 | }
|
---|
41 | }
|
---|