sending Data to jsp Services

sending Data to jsp Services

snapshotsnapshot Posts: 5Questions: 0Answers: 0
edited March 2014 in Editor
I am using the Editor with DataTables 1.10.

I am able to retrieve Data from the Database. How do I save the Data. Here is my code:

editor_B = new $.fn.dataTable.Editor( {
"sAjaxSource": "/DataWarehouseWeb-1.0-SNAPSHOT/RetailSnapshot/plugins/datatables/sources/employeeEdit.jsp",
"domTable": "#cashierTable",

"fields": [
{
"label": "First Name",
"name": "firstName",
"type": "text"
},
{
"label": "Last Name",
"name": "lastName",
"type": "text"
},
{
"label": "Employee #",
"name": "employeeNumber",
"type": "text"
},
{
"label": "Whs Nr",
"name": "whs_num",
"type": "text",
"default": document.getElementById("whs_id").value
}
]
} );
$('#cashierTable').dataTable( {
"destroy": true,
"sAjaxSource": "/DataWarehouseWeb-1.0-SNAPSHOT/RetailSnapshot/plugins/datatables/sources/employeeRead.jsp?Whs=" + document.getElementById("whs_id").value,
"info": false,
"bDeferRender": true,
"bAutoWidth": true,
"scrollY": 100,
"scrollCollapse":false,
"paging" : false,
"order": [ 2, 'asc' ],
"jQueryUI": true,
"jQueryUI": true,
"columns": [
{"sName":"First Name", "sTitle": "First Name", "searchable" : true, "data": "firstName"},
{"sName":"Last Name", "sTitle": "Last Name", "searchable" : true, "data": "lastName"},
{"sName":"Employee #", "sTitle": "Employee #", "searchable" : true, "data": "employeeNumber"},
{"sName":"Whs #", "sTitle": "Whs #", "searchable" : true, "data": "whs_num"}
],

"oTableTools": {
"sRowSelect": "single",
"aButtons": [

{ "sExtends": "editor_create", "editor": editor_B, "sButtonText":"Add New Cashier","title":"Add New Cashier"},
{ "sExtends": "editor_edit", "editor": editor_B },
{ "sExtends": "editor_remove", "editor": editor_B },
/*{ "sExtends": "editor_create", "sButtonText": "Return to Over Short ==>" }*/
],
},
"dom" : '<"H"fT "cec"><"clear"><"F"ip"clear">'

} );

The employeeEdit.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="com.buchheit.datawarehouse.services.*" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="com.element74.core.util.TimestampUtil" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="com.buchheit.datawarehouse.services.cashdrawer.*"%>
<%@ page import="com.element74.core.Element74Properties"%>
<%@ page import="java.math.BigDecimal" %>

<%

CashDrawerService service = new CashDrawerService();
service.setDataSource(Element74Properties.getDataSource());

CashierSaveRequest cInsert = new CashierSaveRequest();
CashierRecord cRec = new CashierRecord();
cInsert.setCashierRecord(cRec);
cRec.setFirstName(request.getParameter("firstName"));
cRec.setLastName(request.getParameter("lastName"));
cRec.setWhsNum(request.getParameter("Whs"));
cRec.setCdCashierId(Long.valueOf(request.getParameter("cashierId")));
cRec.setPublished(true);
cRec.setEmployeeNumber(request.getParameter("employeeNumber"));
CashierSaveResponse cResp = service.saveCashier(cInsert);
%>

Services work. I just dont know how to send the Data from the form create to the employeeEdit.jsp

This is running on a company internal server.

Replies

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    Hi,

    It looks like you probably have the data being sent to the server already - Editor will be submitting an Ajax request with the data when you click the submit button. You can see the Ajax request, and the data payload using your browser's developer tools.

    The format of the data in which Editor submits to the server is documented here: https://editor.datatables.net/server/ . It also has certainly requirements for the data (JSON) that is sent back as a result of the request - also documented on that page.

    If you have any questions about the data submitted or sent back, please do let me know.

    Allan
  • snapshotsnapshot Posts: 5Questions: 0Answers: 0
    Hey Allan, thanks for the answer. My dev. tool is showing the Form Data like this:

    action=create&table=&id=&data%5BfirstName%5D=bbbb&data%5BlastName%5D=rrrr&data%5BemployeeNumber%5D=55555&data%5Bwhs_num%5D=06

    That dose not seem quit right. The %5D should be [
  • ashiersashiers Posts: 101Questions: 8Answers: 7
    Your subject line seems to indicate you're on a Java platform. You might want to check out the JED website which shows how to integrate DataTables with JED on the java platform. Check out http://jed-datatables.ca/jed/
  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    `%5D` is `[` , just URL encoded. Your server should see `[` - assuming it is decoding the url as it should be.

    Allan
  • snapshotsnapshot Posts: 5Questions: 0Answers: 0
    I solved this problem.
This discussion has been closed.