title: Spring Boot Data JPA tables with search, pagination and sorting
body: <p>I'm developing an adminstration interface for a set of tables. I need to implement functionalities such as listing, sorting, filtering and pagination.</p>
  
  <p>I'm using Spring Boot as a starter and Spring Data Jpa for repository. I've searched the Web for some examples about a complete solution that includes all the above functionalities. What I found included almost all of them, but appearently if there was pagination and sorting there wasn't filtering or viceversa.</p>
  
  <p>Now I'm storing the filter in a application object on session using <code>@ModelAttribute</code> but I know that is now a good design because the applciation will extend and it becomes hard to maintain. I'm also using <code>Page</code> and <code>Pagination</code> for pagination purpose and using <code>Specifications</code> for filtering.</p>
  
  <p>What I want is to submit all the data, i.e.: search fields, sorted fields and current page, in a single request. Off course if the search fields are not empty the pagination will be reinitialize. </p>
  
  <p>Another thing is that I don't want to use jQuery  datatables but plain HTML and form submission.</p>
  
  <p>Here are some tutorials and examples that I found:</p>
  
  <p><a href="http://springinpractice.com/2012/05/11/pagination-and-sorting-with-spring-data-jpa" rel="noreferrer">Link 1</a></p>
  
  <p><a href="http://www.petrikainulainen.net/programming/spring-framework/spring-data-jpa-tutorial-part-seven-pagination/" rel="noreferrer">Link 2</a></p>
  
  <p>Thanks in advance</p>
  
  <p><strong>EDIT</strong> html form included</p>
  
  <p>Here is the structure of my table and my pagination section:</p>
  
  <pre><code>&lt;form method=post action=someLink&gt;
      &lt;table&gt; -populated from controller using Thymeleaf - &lt;/table&gt;
      &lt;div class=pagination&gt;
           &lt;ul&gt;  - actually this div is build using the page object returned from server -
              &lt;li&gt;&lt;a href=link/?page=;size=;&gt;1&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=link/?page=;size=;&gt;2&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=link/?page=;size=;&gt;3&lt;/a&gt;&lt;/li&gt;
           &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>As you can see the form is separated from my pagination div. When I click on a page number a get request is send to the server and executes the query with the stored filter. When I submit the form the page number is not taken into consideration because the number of pages can change.</p>
  
  <p>So my question is how to build the form to include the pagination in one single submit.</p>
  
  <p>I'm thinking instead of using a's to use input elements so on the server I can read the data from them. I don't know how to submit that post request with the pageable attributes.</p>
  
  <p>Thanks</p>