Hi, I wanna organize my jTable by paging and sorting it. So, I am working with JSP & servlets. I've created my jTable, but I don't know how to change my controller to paginate my jTable. Here is the part of my code that I have to change in my controller:
CityDAO citydao = new CityDAO();
if(request.getParameter("action")!=null){
List<City> cities = new ArrayList<City>();
String action=(String)request.getParameter("action");
Gson gson = new Gson();
response.setContentType("application/json");
if(action.equals("list")){
try{
//Fetch Data from User Table
cities=CityDAO.selectAll();
//Convert Java Object to Json
JsonElement element = gson.toJsonTree(cities, new TypeToken<List<City>>() {}.getType());
JsonArray jsonArray = element.getAsJsonArray();
String listData=jsonArray.toString();
//Return Json in the format required by jTable plugin
listData="{\"Result\":\"OK\",\"Records\":"+listData+"}";
response.getWriter().print(listData);
}catch(Exception ex){
String error="{\"Result\":\"ERROR\",\"Message\":"+ex.getMessage()+"}";
response.getWriter().print(error);
ex.printStackTrace();
}
}
Hi, I wanna organize my jTable by paging and sorting it. So, I am working with JSP & servlets. I've created my jTable, but I don't know how to change my controller to paginate my jTable. Here is the part of my code that I have to change in my controller:
CityDAO citydao = new CityDAO();
Can someone help me, please ?