5

I want to use Datatable-Plugin of JQuery with JSP. How does the main approach look like?

I want to load the Datatable with AJAX. But my question is how to do it in general with JSP. Normally I'm using JSF with Primefaces but this is much simpler as to do it with JSP (I don't need any Javascript code to use JQuery-Datables example for non-believers).

8
  • Ok, but maybe you know some good links :-) if you dont know the answer. Commented Sep 3, 2013 at 21:53
  • Do you want to load data in table using ajax, or the data is pre-loaded? Commented Sep 3, 2013 at 21:55
  • Did you take a look at the site for Datatables? (datatables.net) Have you made any attempt at using it? Where did you get stuck? Commented Sep 3, 2013 at 21:56
  • @David I want to understand how I can use datatable with JSP. (or some other similar framework) Commented Sep 3, 2013 at 22:04
  • 2
    @JohnN: There are some examples under the "Data Sources" heading here: datatables.net/examples The most common ones I've used are the DOM (for just styling an already-existing HTML table), a JavaScript array (which can be rendered from server-side code) for small amounts of data that should always be on the page, and AJAX (which just makes a request to a server-side resource) for large amounts of data that should be dynamically fetched. For example, take a look at the "aaData" array here: datatables.net/release-datatables/examples/data_sources/… Commented Sep 3, 2013 at 22:18

1 Answer 1

4

You would need to do two specific things:

  1. Create your jsp handler to take a.offset b.pagelength, and make it render json. Lets say you are at this point now (whre you have a variable JSON_DATA)
  2. Use code similar to this pipelined ajax example to make jquery datatables work with your pagination style.

Also, IMO this is a valid question. So UPVOTE.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer! Cool ideas :-) More detailed answer were simpler, but your answer give me the notion.
I use Spring so what is in server_processing at controller file ?? explain Ref:datatables.net/release-datatables/examples/server_side/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.