server-side help

server-side help

lamagylamagy Posts: 11Questions: 0Answers: 0
edited February 2011 in General
hi all,

i've managed to set up an ajax call which dumps all the data to my datatable which naturally doesn't do any sorting or searching..

what do i need to do now, if you can explain to me the next steps in order to get the sorting/searching happening.

can someone give me the run down in what i need to do mvc style because the jsp example on this site its horrible.

thanks,

lamagy.

Replies

  • big-dealbig-deal Posts: 38Questions: 0Answers: 0
    Well, the jsp example isn't horrible - but it is not standart.
    In fact, the jsp example is a great example for how to "translate" a php code into java - without using actual java.

    You are correct that usualy the db handleing part should of not be done in the jsp but in the data access layer - and the logic in the business logic layer.

    More over, in large scale projects we should usualy use ORM (object-relational mapping) such as hibernate, toplink, or even bc4j (adf).

    BUT!
    The jsp example shows you what you should do.

    All you need to do is to "translate" the logic to your technology.

    For example: if you use jsp+servlets and an ORM :
    Your call will be to a servlet that will gather the inputs (sSerach, iDisplayStart, sSearch_0 etc).
    Your servlet than will call a function that will use you ORM to build the needed querys - and calculate them (Filtered, Total, the actual data) - and then will print the to be returned json - like a standart, old fashion, pre jsp era servlets did(: .

    If you are still hacing trouble you can just tell me what technologys you are using and I will try to help.

    I am sure that Allan would appreciate a good java styled example(:
  • lamagylamagy Posts: 11Questions: 0Answers: 0
    ok i'll give it ago.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi folks,

    > I am sure that Allan would appreciate a good java styled example(:

    Certainly would!!! I'm not at all a Java programmer, so I don't really know what is what for how programs are typically laid out in the Java world, so I'm going entirely on contributions here :-). If anyone would like to contribute a different one (applies to any an all languages), it would be most welcome.

    Regards,
    Allan
  • lamagylamagy Posts: 11Questions: 0Answers: 0
    Hi i've made that JSP example into somewhat mvc format, only problem i have is sorting by column is not working, when i click on a column it goes into 'processing' and nothing happens.

    if is go to the ssearch field and type something the column i clicked will be picked up, but it does not sort on its own, any help with this? i'm running spring and apache tiles and the default setup as below.

    var oTable = $('#table1').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "/clientsurvey/marketingSurvey/json.html",

    });
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    If you just get 'Processing' forever, then I'd say it's very likely that you've got an invalid JSON string in the return. You can run it through http://jsonlint.com to check (and get the actual response from Firebug). The server error log might also show something depending on how it is set up.

    Allan
  • lamagylamagy Posts: 11Questions: 0Answers: 0
    Hi Allan,

    My JSon string is ok and validated, i can get results back through the sSearch but it goes funny when i select on a field.

    should the ajaxsource be a 'post' method because at the moment i have the page configured as a Get method.

    also when typing in the search field it is not very responsive upon every key that i enter, sometimes i need to enter an invalid text to respond.

    regards,

    glenn.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Glenn,

    Did you validate the JSON that is returned when you sort on a column? There are only two things I can think of that cause the forever processing issue:

    1. Dodgy JSON (although in jQuery 1.4/5 with the current DataTables you should get a warning about that)
    2. sEcho isn't being updated and sent back as required.

    For the search responsiveness issue, this plug-in will help: http://datatables.net/plug-ins/api#fnSetFilteringDelay . Also with GET and POST - it doesn't matter as long as the server gets what it is expecting. Here is an example of how to have DataTables use POST: http://datatables.net/examples/server_side/post.html

    Allan
  • lamagylamagy Posts: 11Questions: 0Answers: 0
    Thanks for that Alan, that plugin will come in handy.

    i've been debugging my column sorter and the problem is that my rows are not even making a call? i got firebug on and nothing happens when i select a row, it only makes a call when i type on the field. should i create a link on every column to the ajax page? i doubt that is necessary though.
  • lamagylamagy Posts: 11Questions: 0Answers: 0
    Hi allan,

    finally got it to work, i think it was my html format and possibly old corrupted css files, so i changed all that and now working smoooooth.

    let me know if you would like me to post this JSP MVC version, i will need to clean it up but i dont mind posting it somewhere for other java heads can learn much quicker.

    cheers,

    glenn.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Excellent stuff. If you can find time to write up your JSP MVC code, I'm sure it would certainly be of interest to others!

    Regards,
    Allan
This discussion has been closed.