displaytag - maintaining status of checkbox during pagination

Discussions

General J2EE: displaytag - maintaining status of checkbox during pagination

  1. Hi,
    I am using a display tag for pagination in my JSP page. I have a checkbox field as one of the columns. I am using displayTagWrapper class to display my checkboxes. I have a submit button in a page which will save checkbox status into the database. I also have pagination and sorting in the page.

    The problem i have is, i will loose the status of the checkbox when i go to second page. If i select some of the checkboxes in page 1 and go to page 2 to select some more and if i come back, i loose all the selected checkboxes in page 1.

    Is there a way where i could save my check boxes in session and its checked while i browse across pages and gets submitted all at once.

    Any help is appreciated

    Thanks
  2. Is there a way where i could save my check boxes in
    >session and its
    you have to submit your page by some way. E.g. you can make asynch call to your server side on box selection.


    Marina
    http://www.servletsuite.com
  3. But i dont have a way to submit. I am browsing through records and checking the rows i want to submit
  4. Hi,

    i am also facing the same problem, if you have found the solution, plz let me know.

    Thanks,
    Ramesh
  5. You have to catch the click on the header and manage it yourself, in javascript for example. I'm doing it with this piece of code :

    function prepareTableHeader(tableName)
    {
        var table = document.getElementById(tableName);
        var header = table.getElementsByTagName("thead");
        var links = table.getElementsByTagName("a");
        for (i=0; i < rows.length; i++) {
         var curLink = links[i];
    curLink.onclick = function() {
    var target = curLink.search;
    var toadd = target.subString(1,target.length);
    var baseaction = document.forms[0].action;
    if (baseaction.indexOf("?") == -1)
    {
    document.forms[0].action = baseaction + "?" + toadd;
    }
    else
    {
    document.forms[0].action = baseaction + "&" + toadd;
    }
    document.forms[0].submit();
    return false;
    };
        }
    }

    do not forget to call this mehod in the onload of the body tag.

    PS : The submit of my form ensure does not modify anything on the server side (I use a "name" attribute on the submit buttons to select the operation that has to be done. If no operation is selected, I only refresh the screen with the values in the fields on the screen. Spring helps me a lot in doing that)

    I hope it helps.
  6. additional precision :

    I'm doing that to maintain the state of other input fields on the same page than the list when I click on the sort header. You have to adapt it for your own need.
  7. on Submit[ Go to top ]

    I was able to implement the codes successfully (thank you!) however, I cant seem to do any action like copying and deleting my selections.. how can i pass the value of my selections to a submit? Thank you