Search code examples
javascriptjqueryjspspring-mvcdisplaytag

DisplayTag - create first page through Ajax


What I know how to do:

submit a search form through a regular request (not Ajax), and in the new result webpage, show the first page of a table (created by DisplayTag) that can be paginated by Ajax requests (to enable Ajax with DisplayTag I use the jQuery plagin displaytag-ajax ).

What I want to do but do not know how:

I want to create the first page of the table (based on the submitted search form) by Ajax. I.e., I want to submit the search form through Ajax and create the first page of the Ajax-paginable result table in the same webpage of the search form, without loading a new webpage.

Any ideas how this can be achieved?


Solution

  • You can use the jQuery load function to load the response from an AJAX request to a given URL into a div, and you can use the serialize function to transform the set of inputs of your search form into a query string.

    The JSP page used to generate the first page of the table should just generate the table:

    <%@ page ...%>
    <%@ taglib ...%>
    <display:table>
        ...
    </display:table>