title: Dynamically setting content in Geb
body: <p>I want to define a method in a groovy class that I can pass an xpath to on the fly(in order for the same method to be reusable depending on the application). The code snippet below is just a proof of concept, however I would eventually like to build a library of re-usable commands/components, which is why I would like to learn how to dynamically define page content.</p>
  
  <p>If I try this:</p>
  
  <pre><code>import geb.Page;
  
  
  class oneStepDefMethodClass extends Page {
  static url = 'http://www.google.com'
  static content = {
      queryInput { $("input", id: "gbqfq") }   
      queryButton { $("button",name: "btnG") } 
      //songLink { $("span._BZ")} 
  }
  ....
  void assertSongInResults2(String xpathOfSongLink){
      println "Waiting on video link "+ xpathOfSongLink
  
       songLink { $(xpathOfSongLink)}
  
      waitFor {
          songLink.displayed
      }
  }
  
  }
  </code></pre>
  
  <p>I get this error :groovy.lang.MissingMethodException: No signature of method: geb.navigator.NonEmptyNavigator.songLink() is applicable for argument types: (oneStepDefMethodClass$_assertSongInResults2_closure3) values: [oneStepDefMethodClass$_assertSongInResults2_closure3@7c455e96]</p>
  
  <p>If I throw a </p>
  
  <pre><code>content={songLink {$(xpathOfSongLink)}
  }
  </code></pre>
  
  <p>block in the assertSongInResults2 method, I get this error:
  geb.error.UnresolvablePropertyException: Unable to resolve songLink as content for oneStepDefMethodClass, or as a property on its Navigator context. Is songLink a class you forgot to import?</p>
  
  <p>So, yeah is there a way to dynamically define page content like that? The program executes fine if I define it statically up top with the rest of the content , but that is not the point, I want to create re-usable resources instead of redefining the wheel every time I want to use geb.</p>