title: How to display a final range of show pages in Grails?
body: <p>I have domain class objects being added to my database dynamically.</p>
  
  <p>There is the generated index.gsp page which has the table of objects and I want to only display the final 50 objects, NOT all of them. </p>
  
  <p>As of right now this is how the table looks:</p>
  
  <pre><code>&lt;tbody&gt;
  &lt;g:each in="${eventInstanceList}" status="i" var="eventInstance"&gt;
      &lt;tr class="${(i % 2) == 0 ? 'even' : 'odd'}"&gt;
  
          &lt;td&gt;&lt;g:link action="show" id="${eventInstance.id}"&gt;${fieldValue(bean: eventInstance, field: "bandsintown_id")}&lt;/g:link&gt;&lt;/td&gt;
  
          &lt;td&gt;${fieldValue(bean: eventInstance, field: "artist")}&lt;/td&gt;
  
          &lt;td&gt;${fieldValue(bean: eventInstance, field: "ticketStatus")}&lt;/td&gt;
  
          &lt;td&gt;${fieldValue(bean: eventInstance, field: "ticket_url")}&lt;/td&gt;
  
          &lt;td&gt;${fieldValue(bean: eventInstance, field: "venue")}&lt;/td&gt;
  
      &lt;/tr&gt;
  &lt;/g:each&gt;
  </code></pre>
  
  <p></p>
  
  <p>So to reiterate, the code above displays all of my objects in a table - I want to only display the last 50, can anyone help me out here?</p>
  
  <p>UPDATE:</p>
  
  <p>Got it to work with this code in my controller:</p>
  
  <pre><code>def index() 
  {
      int eventCount = Event.count()
      int startingPoint = eventCount - 50
  
      def events = Event.createCriteria().list
      {
          order('id')
          firstResult(startingPoint)
          maxResults(50)
      }
  
      respond events
  }
  </code></pre>