Don't generate lists in your constructor / init methods and set them on the
list.  This is one of the most common pitfalls that newcomers to Wicket fall
in to.  Instead, create a LoadableDetachableModel, ala:

new ListView("list", new LoadableDetachableModel<List<Person>>() {
  public List<Person> load() {
     // note that of course, you could add an auto-injected dao to your
component
    return App.get().getYourDAO().findPeople();
  }
});

This accomplishes two things:
1 - doesn't serialize the whole list to the session
2 - if another component modifies the list, the list is auto-refreshed.

This is the classic "push" vs "pull" method.  You should prefer the pull.

--
Jeremy Thomerson
http://www.wickettraining.com



On Fri, Mar 5, 2010 at 3:22 PM, Eric Reagan <reaga...@gmail.com> wrote:

> Hi,
>      I am still new to Wicket and I think I might be missing something. I
> am trying to create a list of items and then have a panel generate a
> ListView which contains the previously created list (and all their children
> and children's children..etc). In order to do this I created a class for
> the
> List Items (ListItem) and a panel called (ListItemPanel). In order to
> generate the ListView in my panel I need to be able to tell the panel which
> list I want to iterate over. In order to do this in the calling page I made
> my list and I went to go and set my variable inside of my panel, but my
> setListToView(...) method which I had created won't appear. I have included
> below the problem snippets. Thank you in advance for the help.
>
> // Code
>
> MyPage
>    ............
>    ListItemPanel panel = new ListItemPanel("panel");
>     ......generate all of the list items and put it into an ArrayList
>     panel.setListToView(...panels) <--------This method can't be called
> even though its a public method in my ListPanel class which extends Panel
>
> thank you,
>
> --
> Eric Reagan
>

Reply via email to