On 3/15/08, Matej Knopp <[EMAIL PROTECTED]> wrote: > Not wit url like http://localhost:8080/. That's a homepage URL. It > doesn't contain any information about page instance, etc. so wicket > has to create new page instance. > > Transparent back button support is about something else. Wicket tracks > certain changes to page, i.e. adding or removing components which > triggers new page version. But in order to revert to previos page > version the URL must be either a listener interface url > (?wicket:interface=...) or a hybrid URL. So you can try to mount your > home page using HybridUrlCodingStrategy. Also just incrementing a > property will not trigger new page version. Wicket can't introspect > every property in your component hierarachy to determine that a new > page version should be created, that would be way too slow. > > To get wicket to create new page version when you increment your > counter you might want to call label.modelChanging() on your link > click handler. (You need to do this because you are just incrementing > a property, not changing component hierarchy or something else that > wicket can detect). > > When new page version is created you should see a version number > incrementing in your url. On back button the URL should contain > previous version number. >
Ok, I've followed your instructions. Here's my new Application class: public class WicketApplication extends WebApplication { protected void init() { mount(new HybridUrlCodingStrategy("/Home.page", HomePage.class)); } public Class getHomePage() { return HomePage.class; } } Here's my HomePage class: public class HomePage extends WebPage { private static final long serialVersionUID = 1L; private static final Logger log = LoggerFactory.getLogger(HomePage.class); private int counter; public HomePage() { log.info("I'm (identity " + System.identityHashCode(this) + ") being instantiated." ); final Label label = new Label("message", new LoadableDetachableModel() { protected Object load() { return "I've been called " + counter + " times."; } }); add(label); add(new Link("refreshLink") { public void onClick() { counter++; log.info("I'm being called on object with identity " + System.identityHashCode(HomePage.this)); label.modelChanging(); } }); } protected Object writeReplace() throws ObjectStreamException { final Object replacement = super.writeReplace(); log.info("I'm (identity " + System.identityHashCode(this) + ") being write replaced by object " + replacement); return replacement; } } When I go to http://localhost:8080/, it redirects me to http://localhost:8080/Home.page.0 and that generates the following HTML: <html> <head> <title>Wicket Quickstart Archetype Homepage</title> </head> <body> <strong>Wicket Quickstart Archetype Homepage</strong> <br/><br/> <span wicket:id="message">I've been called 0 times.</span> <p> Click <a href="?wicket:interface=:0:refreshLink::ILinkListener::" wicket:id="refreshLink">here </a> to refresh me! </p> </body> </html> Now, when I click the link, the URL changes to http://localhost:8080/Home.page.0.1. So, the back button works and shows me exactly what I wanted to see! Thank you for all your help! By the way, modelChanged() and modelChanging() do two completely different things! It doesn't work if I try modelChanged(), but it does work if I do modelChanging(). It's not completely obvious what the distinction is from the Javadocs (when do you call one vs. the other). We might want to explain it a bit better. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]