2010/7/7 西门烧雪 Simon <sekatsi...@gmail.com> > I have read that "in Wicket a page is only constructed once", from > https://cwiki.apache.org/WICKET/reading-from-a-database.html > > So I did an experiment with the following class. When I press F5 > twice in my browser to refresh, and I get the print out (see below) > three times. So, is the statement "in Wicket a page is only > constructed once" correct? > > public class Echo extends WebPage { > > public Echo() { > System.out.println(this.toString()); > } > > } > > Print out: > > [Page class = org.appfuse.web.pages.echo.Echo, id = 0, version = 0] > [Page class = org.appfuse.web.pages.echo.Echo, id = 1, version = 0] > [Page class = org.appfuse.web.pages.echo.Echo, id = 2, version = 0] > > Thank you > > -- > Simon > 西门烧雪 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > You were on a bookmarkable page. The statement should be qualified. Every time you hit a bookmarkable page, or redirect to a page via setResponsePage(Class) or setResponsePage(Class, PageParameters), you will create a page. But, for all stateful redirects, including stateful actions within the page, the page is not reconstructed.
Try this: add a private int counter to your page class. Then add the following component and click the link: add(new Link("link") { public void onClick() { System.out.println("link was clicked - same instance of page"); System.out.println(++counter); } }); -- Jeremy Thomerson http://www.wickettraining.com