Datatables delete/update problems

Datatables delete/update problems

KlaqKlaq Posts: 8Questions: 0Answers: 0
edited May 2012 in General
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?

Replies

  • allanallan Posts: 63,397Questions: 1Answers: 10,451 Site admin
    What Javascript are you using to call DeleteData?

    Allan
  • KlaqKlaq Posts: 8Questions: 0Answers: 0
    I'am calling DeleteData from Delete button, not using additional scripts
    [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?
  • allanallan Posts: 63,397Questions: 1Answers: 10,451 Site admin
    That sounds about right, but I'm afraid I'm not particularly familiar with the makeEditable plug-in, so I'm afraid I can't offer much advice. If I recall correctly you need to specify the URL (i.e. the servlet) that you want to use the delete function with.

    Allan
  • KlaqKlaq Posts: 8Questions: 0Answers: 0
    You right, Allan, thanks. So, i tried debug with firebug, POST DeleteData message exists and this action calling DeleteData servlet. But request.getParameterNames() in servlet is empty and it means I didn't get any parametres by POST. Can you assume whats wrong?
  • KlaqKlaq Posts: 8Questions: 0Answers: 0
    Yes, even after deleting row disappear from table, but naturalle not from MySQL table) So, question is how to get row data using defined DeleteData URL.
This discussion has been closed.