This worked GREAT! Thank you. On Sat, Jan 21, 2012 at 2:51 PM, Sven Meier <s...@meiers.net> wrote: > Use a LoadableDetachableModel to load a fresh list of movies on each > request. > > Sven > > > On 01/21/2012 10:35 PM, Daniel Watrous wrote: >> >> I'm creating a small app based on the guestbook: >> http://www.wicket-library.com/wicket-examples/guestbook/?1 >> >> In the guestbook app, the page view is updated every time a new >> comment is added. The variable commentList is initialized at the top >> like this >> >> private static final List<Comment> commentList = new >> ArrayList<Comment>(); >> >> // Add commentListView of existing comments >> add(new PropertyListView<Comment>("comments", commentList) >> { >> @Override >> public void populateItem(final ListItem<Comment> listItem) >> { >> listItem.add(new Label("date")); >> listItem.add(new MultiLineLabel("text")); >> } >> }).setVersioned(false); >> >> I wanted to use a database instead, so I made the following changes >> >> private List<Movie> movieList = new ArrayList<Movie>(); >> >> Session session = >> HibernateUtil.getSessionFactory().getCurrentSession(); >> session.beginTransaction(); >> movieList = session.createQuery("from Movie").list(); >> session.getTransaction().commit(); >> >> // Add commentListView of existing comments >> add(new PropertyListView<Movie>("movies", movieList) { >> >> @Override >> public void populateItem(final ListItem<Movie> listItem) { >> listItem.add(new >> TextField<String>("name").setType(String.class)); >> listItem.add(new DropDownChoice<Category>("category", >> Arrays.asList(Category.values()), new >> EnumChoiceRenderer<Category>(this))); >> listItem.add(new Label("rating")); >> } >> }).setVersioned(false); >> >> With this change, all the items in the database come up when the page >> first loads, but not after each new item is added to the database. I >> have to clear out the URL and load the page fresh to see what has been >> added since the last fresh load. >> >> I did try resetting movieList in the onSubmit function to load the >> current database items into the variable movieList, but that still >> doesn't update the list. >> >> Any idea how to update movieList after each new item is submitted. >> >> Daniel >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org