title: How to filter Groovy/Grails closure from web app
body: <p>I have a web app that makes a call to a grails app for its db calls.  The db is filled with products that are returned through groovy calls.  An example object that I would get from the db is as follows:</p>
  
  <pre><code>class Product{
      Boolean is_blue;
      Boolean is_round;
      Boolean is_alive;
      Boolean is_active;
      String type;
      String name;
  }
  </code></pre>
  
  <p>I want to make a call to the grails app to filter on these boolean values but I am not sure how to do it via a closure, this what my closure currently looks like.</p>
  
  <pre><code>def productXML = 
       Product.findAll("from Product as p where p.is_active = 1 and p.type = :type 
                        ORDER BY p.${params.sort} ${params.order}", 
                        [type: type], [max: params.max, offset: params.offset])
  </code></pre>
  
  <p>What I'm most confused on is how I can pass these parameters to the closure. Any help would be greatly appreciated. Thanks.</p>