Forum


21:33

07/12/2010

Hi everyone
I've trying to adapt the 'My First Grid' from the jqgrid wiki to use it with jsp instead of php, but I stil can do it.What do I need to change? Is it neccesary to add page,limit,count,total_pages, etc to the session?
private Integer page;
private Integer limit;
private Integer count, total_pages, start;
private String sidx = null;
private String sord = null;
private String s = null;
HttpSession session = null;
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
session = request.getSession();
page = Integer.parseInt(request.getParameter("page"));
limit = Integer.parseInt(request.getParameter("rows"));
sidx = request.getParameter("sidx");
sord = request.getParameter("sord");
if (!sidx.equals("")) {
sidx = "invid";
}
RNPrueba facade = new RNPrueba();
List<Prueba> tab = new ArrayList(1);
//'ContarConsultarTodos' calculates the number of rows for the query
count = facade.ContarConsultarTodos();
if (count > 0 && limit > 0) {
total_pages = (int) (count / limit);
} else {
total_pages = 0;
}
if (page > total_pages) {
page = total_pages;
}
start = limit * page – limit;
if (start < 0) {
start = 0;
}
//'ConsultarTodos' gets all the rows
tab = facade.ConsultarTodos(sidx, sord, start, limit);
s = "<?xml version='1.0' encoding='utf-8'?>";
s += "<rows>";
s += "<page>" + page + "</page>";
s += "<total>" + total_pages + "</total>";
s += "<records>" + count + "</records>";
for (int i = 0; i < tab.size(); i++) {
s += "<row id='" + tab.get(i).getInvid() + "'>";
s += "<cell>" + tab.get(i).getInvid() + "</cell>";
s += "<cell>" + tab.get(i).getInvdate() + "</cell>";
s += "<cell>" + tab.get(i).getAmount() + "</cell>";
s += "<cell>" + tab.get(i).getTax() + "</cell>";
s += "<cell>" + tab.get(i).getTotal() + "</cell>";
s += "<cell><![CDATA[" + tab.get(i).getNote() + "]]></cell>";
s += "</row>";
}
s += "</rows>";
System.out.println(s);
return new ModelAndView("mantenimiento.prueba");
} }
Another thing I don't know how to adapt is this:
header("Content-type: text/xml;charset=utf-8");
And since the java code (shown above) inside the SourcePackages in a package called: 'Mantenimiento' I'd would like to know, how I have to call this file (MantenimientoPrueba.java) from my jsp file , that is where the jqgrid is.
$(function(){
$("#list").jqGrid({
url:'mantenimientoprueba.htm',
//...some other code
});
Should I use this url?, which is the name I give to MantenimientoPrueba.java in the spring-servlet.xml,or shoul I just use MantenimientoPrueba.java?
I really hope you can help me out,thanks in advance
PS:I'm using Jsp with Spring and … sorry for my bad English
Most Users Ever Online: 715
Currently Online:
45 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66