title: conditions inside g:select gsp tag
body: <p>I am using g:select and wishes to put a default selected value. However when default value is null it should display a 'Please select one'. However, I cannot seem to work it out. </p>
  
  <p>Code is below:</p>
  
  <p>This is the Address object - options contained in a drop down</p>
  
  <pre><code>Address
      Long id
      String name
      Sheriff sheriff
      String phaseCode
  </code></pre>
  
  <p>ListOfSheriffs is a list of sheriffs-contains list of Sheriff object</p>
  
  <pre><code>Sheriff
      Long id
      String name
      //other property here
  </code></pre>
  
  <p>defaultSheriff is the default sheriff of an Address</p>
  
  <p>The below code is one on my gsp</p>
  
  <pre><code>&lt;g:select optionKey = "id" 
            optionValue = "${{sheriff.name +' '+sheriff.id}}"  
            name="sheriff.name"
            from="${ListOfSheriffs}"
            value="${(defaultSheriff == null) ? 'Please select one' : defaultSheriff}" /&gt;
  </code></pre>
  
  <p>However, wether defaultSheriff is null 'Please select one' wont display, the page only displays the first sheriff from the ListOfSheriffs.</p>
  
  <p>I got this solution from <a href="https://stackoverflow.com/questions/12507918/grails-gif-in-gselect">here</a>
  . And not so sure what I left out.</p>
  
  <p>Also, I tried using noSelection based on what I've read on <a href="http://grails.github.io/grails-doc/1.3.6/ref/Tags/select.html" rel="nofollow noreferrer">docs</a>. However, the result is, the default selected value on dropdown list on the page is always 'Please select one' even though the defaultSheriff is not null</p>
  
  <pre><code>&lt;g:select optionKey = "id" 
            optionValue = "${{sheriff.name +' '+sheriff.id}}"  
            name="sheriff.name"
            from="${ListOfSheriffs}"
            value="${defaultSheriff}"
            noSelection="[null:'Please select one']" /&gt;
  </code></pre>
  
  <p>If something is not clear with what I have provided, feel free to point it add, I'll be happy to detail it. thanks</p>