Hi, Here is a small demo application: https://github.com/martin-g/blogs/tree/master/ajax-history It uses HTML5 History API directly, so it won't work on old Internet Explorers! If you need to support old IE, good luck finding a decent JS library. AFAIK https://github.com/browserstate/history.js is one of the best out there, but looking at the number of open issues and PRs I wouldn't use it in my applications.
The demo application shows how to support Ajax history for "Ajax menu" use case from the earlier mails in this thread. In the past I have used something similar for Ajax pagination functionality. The menu items show how to change the url's path, query string and/or fragment The impl just triggers the respective JS event on the respective Ajax component for the history event. The rest is normal Wicket Ajax request. As noted in the previous mail by clicking the browser's back button you will not ask Wicket to load an old version of the page! From Wicket point of view the navigation in the page always goes forward! This implementation is not in Wicket itself because I am sure it is not generic enough for everyone's use cases (and because History API is not available in old IEs!). if you need help with a use case that doesn't work with this impl then please create a demo application and I'll try to help! If one day the implementation is generic enough it may land in Wicket! Have fun! Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Wed, Jul 13, 2016 at 10:55 AM, Wayne W <[email protected]> wrote: > Hi, > > On Thu, Jul 7, 2016 at 11:28 PM, Martin Grigorov < > [email protected]> > wrote: > > > Hi, > > > > It seems you use Wicket for several years now and you have no idea how to > > use it! > > > > > Yes perhaps Martin, I do try but there's a lot too it. > > > > > > I have done this for a client of mine 4 years ago. > > And I have explained how to do it few times in the mailing lists. > > You could use HTML5 History API to manipulate the browser url on each > Ajax > > call. If you need to support old browsers (why?! almost no one does these > > days) then you should use some JS library that falls back to using the > > location fragment/hash. > > The support of "back/forward" buttons is just registering an > > AjaxEventBehavior that listens for "popState"/"hashchange" event. > > > > > I did some extensive searching and only found a couple of threads about > this: > > > http://apache-wicket.1842946.n4.nabble.com/Wicket7-History-API-support-for-navigable-AJAX-pages-components-td4660502.html > > > The main issue seems that the page map is not updated (just overriden) for > ajax requests from my reading before. I came to the conclusion trying to > get wicket to support the back button would be difficult and somewhat > hacky. It seems we'd end up with unknown behaviour and issues possibly > occurring and therefore too much of a risk. Hence this thread. > > > > > > > I will try to find time to write a blog article with a demo app at > > wicketinaction.com soon. > > > > > > That would be great. > > > > > > > > >
