title: Wicket - DropDownChoice with object Selected
body: <p>Im having problem with a DropDownChoice. I have to pre-selected an item but every tutorial and example I have found, only consider a list of primitive type.</p>
  
  <p>I have a list of Object. 
  </p>
  
  <pre class="lang-java prettyprint-override"><code>class myObject {
     private String name;
     private String surname;
     [setter and getter]
  } 
  </code></pre>
  
  <p>In other class</p>
  
  <pre class="lang-java prettyprint-override"><code>List&lt;MyObject&gt; myList = some_data_retrieve();
  MyObject defaultValue = some_simple_data_retrieve();
  </code></pre>
  
  <p>To build the DropDownChoice im using the following constuctor:</p>
  
  <pre class="lang-java prettyprint-override"><code>final DropDownChoice&lt;T&gt; ddc = new DropDownChoice&lt;T&gt;(id, data, new ChoiceRenderer&lt;T&gt;(choiceRendererExpression, choiceRendererIdExpression));
  </code></pre>
  
  <p>In this way:</p>
  
  <pre class="lang-java prettyprint-override"><code>final DropDownChoice&lt;myObject&gt; ddc = new DropDownChoice&lt;myObject&gt;("wicket_id", myList, new ChoiceRenderer&lt;myObject&gt;("name", "surname"));
  </code></pre>
  
  <p>Now. In every tutorial/example they use another constructor with a Model. For example:</p>
  
  <pre class="lang-java prettyprint-override"><code>private static final List&lt;String&gt; SEARCH_ENGINES = Arrays.asList(new String[] {
          "Google", "Bing", "Baidu" });
  private String selected = "Google";
  DropDownChoice&lt;String&gt; listSites = new DropDownChoice&lt;String&gt;(
          "sites", new PropertyModel&lt;String&gt;(this, "selected"), SEARCH_ENGINES);
  </code></pre>
  
  <p>I have tried something like this to emulate that kind of call:</p>
  
  <pre class="lang-java prettyprint-override"><code>final DropDownChoice&lt;myObject&gt; ddc = new DropDownChoice&lt;myObject&gt;("wicket_id", new PropertyModel&lt;myObject&gt;(this,"defaultValue"),myList, new ChoiceRenderer&lt;myObject&gt;("name", "surname"));
  </code></pre>
  
  <p>But what I got is an error:</p>
  
  <pre class="lang-java prettyprint-override"><code>No get method defined for class: package$WicketPage expression: defaultValue
  </code></pre>
  
  <p>Please, help me undersand.</p>
  
  <p>Thanks</p>