jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › success in populating my grid using jsp and serlvet but updating is a problem
This topic contains 0 replies, has 1 voice, and was last updated by ekpes 12 years, 3 months ago.
-
Author
-
March 30, 2013 at 2:26 pm success in populating my grid using jsp and serlvet but updating is a problem #18299
Gridservlet.java which has a url pattern as gridserve.jsp
…………………….
the source code for Gridservlet.
package schoolBook.digiworld.controller;import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.JSONArray;
import schoolBook.digiworld.model.UserDocument;
import schoolBook.digiworld.model.UserDocumentTwoDAO;/**
*
* @author Felix
*/public class GridServlet extends HttpServlet {
/**
* Processes requests for both HTTP
*GET
and
*POST
methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {try
{
response.setContentType(“application/json”);
response.setCharacterEncoding(“UTF-8”);
HttpSession session = request.getSession(false);
// String username = (String) session.getAttribute(“username”);UserDocumentTwoDAO dao = new UserDocumentTwoDAO();
List list = dao.viewAllDocumentsforThisUser(“ekpes”);
JSONArray array = new JSONArray(list);PrintWriter out = response.getWriter();
// writing the json-array to the output stream
out.print(array);
out.flush();}
catch(Exception xcp)
{}
}//
/**
* Handles the HTTP
*GET
method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}/**
* Handles the HTTP
*POST
method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return “Short description”;
}//
}JSP code
………………………..
page contentType=”text/html” pageEncoding=”UTF-8″%>$(document).ready(function () {
var theme = ‘darkblue’;
var url = ‘gridserve.jsp’;// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ‘id’ },
{ name: ‘daterecieved’ },
{ name: ‘message’ },
{ name: ‘nameofrecipient’ },
{ name: ‘documentmode’ },
{ name: ‘filesize’ },
{ name: ‘filename’ },
{ name: ‘datecreated’ },
{ name: ‘datemodified’ },
],
id: ‘id’,
url: url
/* updaterow: function (rowid, rowdata) {
// synchronize with the server – send update command
}*/
// localdata: dataResult
};
var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid(
{
width: 1550,
source: dataAdapter,
pageable: true,
selectionmode: ‘singlecell’,
editable: true,
filterable: true,
sortable: true,
autoheight: true,
enabletooltips: true,
altrows: true,
theme: theme,
columns: [
{ text: ‘ID’, datafield: ‘id’, width: 70 },{ text: ‘Name’, datafield: ‘filename’, width: 250 },
{ text: ‘Doc Mode’, datafield: ‘documentmode’, width: 120 },
{ text: ‘Date Recieved’, datafield: ‘daterecieved’, width: 250 },
{ text: ‘Message’, datafield: ‘message’, width: 250 },
{ text: ‘Recipient’, datafield: ‘nameofrecipient’, width: 180 },
{ text: ‘Size’, datafield: ‘filesize’, width: 250 },{ text: ‘Created Date’, datafield: ‘datecreated’, width: 180 },
{ text: ‘Modified Date’, datafield: ‘datemodified’, width: 120 }
]
});
});here is the result.
-
AuthorPosts
You must be logged in to reply to this topic.