Client and Server-Side implementation with Servlets
Client and Server-Side implementation with Servlets
Hello,
i need help to implement the Editor to a existing environment where DataTables running with several Servlets.
This is the existing code for run DataTables:
main.js
var table = $('<table cellpadding="0" cellspacing="0" border="0" class="stripe" id="sql-request-data-table"></table>');
var tableHeader = [];
$.each(queryDataResponse.ResultSet[0], function(key, value) {
tableHeader.push({"data": key});
});
table = table.DataTable({
"data": queryDataResponse.ResultSet,
"columns": tableHeader,
"searching": false,
"paging": false
});
$.each(tableHeader, function(index, value) {
$(table.column(index).header()).html(value.data);
});
My question is how to implement the Editor in this existing code?
Further what Type of Date comes out of the Editor wenn editing/deleting/create an row.
I should now this for handling in the servlet.
Sry for my bad english... and
Thanks for help.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
The client-sever communication protocol that Editor uses is documented in the manual.
Allan
Ok ...
And how can i implement the Editor in this code?
Your
/EditorServlet
servlet would need to implement the client / server protocol that I linked to above.If you have any questions about that protocol, please let me know.
Allan
I'm sorry for the stupid questions. :-( I need this for my "bachelor work".
But the implementation of the Editor in den above code is right?
For better understanding: I need an Editor an an DataTabels instance for a working Editor?
For what i need the
in the EditorInstance and the
in DataTablesInstance?
i don't have any idea for the EditorServlet because now i know the Parms but i don't know to use right.
To access the Parms i must use request.getParameter("action"/"data"/"id"); ?
Many thanks for your help!
Yes, your code looks fine if you add the fields and columns as you mention. What exactly you should add depends upon what data you get in
queryDataResponse.ResultSet
. What does that data look like?Honestly? Absolutely no idea :-). I know next to nothing about Java. If you need help with Java programming I would suggest asking on StackOverflow or a Java specific site.
Regards,
Allan
When the Editor and DataTables Code looks like good then should the Java Part not be a problem.
As ResultSet comes a JSONArray with the rows of a mysql select query.
This is a particular excerpt of the JavaServlet for the existing DataTables plugin
I wont try the jsp Code but it don't work! :-(
Firefox -> Konsole - ReferenceError.. line 4
Whats wrong with this code?
Normally
table
should be a string - like in all of the examples.But without a link to the page, I can't say for certain.
Regarding the Java, as I say, I don't know Java. Can you show me what the JSON output that this provides is please.
Allan
This code where placed in the main.js and produce an Error but i don't know what is wrong.
// TypeError: $.fn.dataTable.Editor is not a constructor
Can you tell me what's wrong?
And in the index.html i implement:
Change the code load order:
jQuery first, then just one DataTables, followed by TableTools and then Editor.
Allan
I have saved the changes but it have no effects.
The window shows nothing and the console log "TypeError: $.fn.dataTable is undefined"
Do you have any idea?
Separately in what form/type sends the Editor the data object to Server?
Can you show me an example?
I linked to the documentation for how the data is sent to the server above - Editor manual.
Can you give me a link to the page please? Also check that you aren't loading jQuery multiple times.
Allan
Thats all who loaded by the index.html
I've just replied to your PM. Looks like there are 404 errors which is causing the issue.
Allan
Server to Client Data
Create:
Is it important that the ID Param Value exactly "row_1" or "row_12" is or should this param mirroring the real mysql ID value "1" "12"?
Why does the ID not in the HttpResponse Parameters?
The reason my Editor libraries add
row_
as a prefix is that it makes it a valid HTML4 and CSS id. An id starting with a number is not a valid id. It means that extra work needs to be done to add and remove the prefix, but it does help.It looks like it is - in the
DT_RowId
parameter.Allan
How i can send form Client-Side to the Server extra Parameters like TableName?
Use the
ajax.data
option. For DataTables' requests useajax.data
.Allan