title: Grails: problem with paging and ordering in a view template
body: <p>How do I structure my pages and partial templates so that Ajax will play nice with <code>&lt;paginate&gt;</code> and column sorting?</p>
  
  <p>I currently have a search.gsp page with a remoteField that calls a controller to update a template. This all works fine. However, the column sorting and paging actions cause my search.gsp to be completely replaced by the template view. </p>
  
  <p>From my search.gsp:</p>
  
  <pre><code>&lt;div id="searchBox"&gt;
    Enter a key or phrase: &lt;g:remoteField  name="searchBox"  
                           update="resourceSearchResultPanel" paramName="q"                                            
                           url="[controller:'resourceEntry',action:'searchForResources']" 
                           /&gt;
  &lt;/div&gt;
  &lt;div id="resourceSearchResultPanel" /&gt;
  </code></pre>
  
  <p>My controller handles the search request like so:</p>
  
  <pre><code>def searchForResources = {
          params.max = Math.min(params.max ? params.max.toInteger() : 10, 100)
          params.offset = params.offset ? params.offset.toInteger() : 0
          log.debug "Handling search post action"
          def q = params.q ?: null
          log.debug "Search phrase is $q"
          def searchResults
          if (q) {
              searchResults = [
                  results: ResourceEntry.search(q,[offset: params.offset, max: params.max]),
                  resultCount: ResourceEntry.countHits(q),
                  q: q.encodeAsHTML()
              ]
          }
          render(template:"resourceSearchResultPanel",model:searchResults)
      }
  </code></pre>
  
  <p>The _resourceSearchResultPanel.gsp is just a table with this <code>&lt;paginate&gt;</code> tag:</p>
  
  <pre><code>&lt;g:paginate action="searchForResources" total="${resultCount}" params='["q":"${q}"]'  /&gt;
  </code></pre>
  
  <p>The problem is that when the <code>&lt;paginate&gt;</code> tag calls the controller, the entire page is refreshed with the contents of the _resourceSearchResultPanel.gsp template, while I just want the _resourceSearchResultPanel.gsp itself to be refreshed inside search.gsp. </p>
  
  <p>There's no <code>update</code> attribute like there is in the <code>remoteField</code> tag...</p>