Datatables delete/update problems
Datatables delete/update problems
I'am using datatables with java beans, datasourse MySQL. Adding new record is OK, but i can't delete/update records. I guess, the problem in requesting via servlet. For simplifyng I using non-serverside method. Servlet name "/DeleteData", same url, and when debugging this servlet I'am receiving null in request.getParameterNames(), so there is no parameters sending. Initialisation code:
[code]
$('#cfo').dataTable( {
"sScrollY": "400px",
"bScrollCollapse": true,
"bPaginate": true,
"bJQueryUI": true,
"asStripClasses": null,
"sAjaxSource": "/Dp/cfo",
"aoColumns": [
{ "mDataProp": "idCFO",
"bSearchable": false,
"bSortable": false,
"bVisible": false},
{ "mDataProp": "kod" },
{ "mDataProp": "name" },
]
}
[/code]
HTML:
[code]
Код ЦФО
Наименование
Add
Delete
ID
Код
Наименование ЦФО
[/code]
Servlet AddData code (which is working properly):
[code]
@WebServlet(name = "/AddData",
urlPatterns = {"/AddData"})
public class AddData extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB
private CfoFacade cfoFacade;
public AddData() {
super();
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
BeanToJson beanToJson = new BeanToJson();
JsonObject jsonResponse = new JsonObject();
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
String id = request.getParameter("id");
if (id.equals("cfo")) {
String kod = request.getParameter("kod");
String name = request.getParameter("name");
Cfo c = new Cfo();
c.setKod(kod);
c.setName(name);
cfoFacade.create(c);
JsonArray o = beanToJson.BeanToJson(cfoFacade.findAll());
jsonResponse.add("aaData", o);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().print(jsonResponse.toString());
}
}
[/code]
So, the same servlet "/DeleteData" doesn't work and I can't get any parameters. Do you have any ideas?
Do you have any ideas?
[code]
$('#cfo').dataTable( {
"sScrollY": "400px",
"bScrollCollapse": true,
"bPaginate": true,
"bJQueryUI": true,
"asStripClasses": null,
"sAjaxSource": "/Dp/cfo",
"aoColumns": [
{ "mDataProp": "idCFO",
"bSearchable": false,
"bSortable": false,
"bVisible": false},
{ "mDataProp": "kod" },
{ "mDataProp": "name" },
]
}
[/code]
HTML:
[code]
Код ЦФО
Наименование
Add
Delete
ID
Код
Наименование ЦФО
[/code]
Servlet AddData code (which is working properly):
[code]
@WebServlet(name = "/AddData",
urlPatterns = {"/AddData"})
public class AddData extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB
private CfoFacade cfoFacade;
public AddData() {
super();
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
BeanToJson beanToJson = new BeanToJson();
JsonObject jsonResponse = new JsonObject();
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
String id = request.getParameter("id");
if (id.equals("cfo")) {
String kod = request.getParameter("kod");
String name = request.getParameter("name");
Cfo c = new Cfo();
c.setKod(kod);
c.setName(name);
cfoFacade.create(c);
JsonArray o = beanToJson.BeanToJson(cfoFacade.findAll());
jsonResponse.add("aaData", o);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().print(jsonResponse.toString());
}
}
[/code]
So, the same servlet "/DeleteData" doesn't work and I can't get any parameters. Do you have any ideas?
Do you have any ideas?
This discussion has been closed.
Replies
Allan
[code]
.makeEditable({
sAddNewRowFormId: "formAddNewRow2",
sAddNewRowButtonId: "btnAddNewRow2",
sAddNewRowOkButtonId: "btnAddNewRowOk2",
sAddNewRowCancelButtonId: "btnAddNewRowCancel2",
sDeleteRowButtonId: "btnDeleteRow2",
oAddNewRowButtonOptions: {
label: "Добавить",
icons: { primary: 'ui-icon-plus' }
},
oDeleteRowButtonOptions: {
label: "Удалить",
icons: { primary: 'ui-icon-trash' }
},
oAddNewRowOkButtonOptions: {
label: "ОК",
icons: { primary: 'ui-icon-check' },
name: "action",
value: "add-new"
},
oAddNewRowCancelButtonOptions: {
label: "Закрыть",
name: "action",
value: "cancel-add",
icons: { primary: 'ui-icon-close' }
},
oAddNewRowFormOptions: {
show: "drop",
hide: "drop",
modal: true,
"minHeight":250,
"minWidth": 500
}
});
[/code]
The same way I've used when calling AddData from modal formAddNewRow2. I define servlet names like in example http://www.codeproject.com/Articles/193068/Adding-data-management-CRUD-functionalities-to-the and I think this names (AddData and DeleteData) are pre-defined. So I think the problem is know how Delete button working whith servlets. Am I right?
Allan