title: Making a model of an item from a list model in wicket
body: <p>Wicket Version: 6.14</p>
  
  <p>I have a </p>
  
  <pre><code>LoadableDetachableModel&lt;List&lt;Foo&gt;&gt;
  </code></pre>
  
  <p>I am trying to use the model with a wizard but each page of the wizard will use a single item of the list.</p>
  
  <p>I want to get a model of each in the list and change the model between each screen in the wizard.</p>
  
  <p>Ideally I could do something like this:</p>
  
  <pre><code>PropertyModel&lt;Foo&gt; fooItemModel = new PropertyModel&lt;Foo&gt;(fooItems, "get(0)");
  </code></pre>
  
  <p>One other idea I have had is to roll my own ListItemModel and make it take an </p>
  
  <pre><code>IModel&lt;List&lt;?&gt;&gt;
  </code></pre>
  
  <p>instead of a ListView.</p>
  
  <pre><code>public ListItemModel(final ListView&lt;T&gt; listView, final int index)
  {
      this.listView = listView;
      this.index = index;
  }
  
  /**
   * @see org.apache.wicket.model.IModel#getObject()
   */
  @Override
  public T getObject()
  {
      return listView.getModelObject().get(index);
  }
  
  /**
   * @see org.apache.wicket.model.IModel#setObject(java.lang.Object)
   */
  @Override
  public void setObject(T object)
  {
      listView.getModelObject().set(index, object);
  }
  </code></pre>
  
  <p>Any advice is appreciated in advanced</p>