+1 for the change.

Eelco

Johan Compagner wrote:

Hi

the ListItem constuctor that is used by ListView to create the listitems does this:

   protected ListItem(final int index, final ListView listView)
   {
       this(index, new Model(listView.getListObject(index)));

       this.listView = listView;
   }


this is in my eyes very bad behaviour. Because what happens here is that something from a Model of the ListView
is copied into a standard model for every ListItem. So if the listview/table has a DetachableListModel so that
we clean the list after every request. The ListItem still holds the object!
Besides that listItem.getModelObject() returns a hibernate object that is transient
(that can't be used by the current hibernate session)


So what ListItem should do is this:


protected ListItem(final int index, final ListView listView) { this(index, new ListItemModel());

       this.listView = listView;
   }

private class ListItemModel extends Model
   {
       /*
        * @see wicket.model.Model#getObject()
        */
       public Object getObject()
       {
           return listView.getListObject(index);
       }
  }

So the listview should get the object it wants always from the Listview model.

Any objections against this change?

johan



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to