JSF, Ajax, and the Back Button

For the last few weeks I have been trying to integrate back button support into a JSF/Ajax app as an "Undo" feature. I have been using 2 approaches, 1) g4jsf (a subproject of Ajax4JSF) to enable use of GWT, and 2) dojo.undo.browser.

Currently, any engineer interacting with the back button through javascript only has access to a few methods. window.history.current, window.history.next, window.history.previous, and an array of history items with window.history[]. Gwt and dojo give us a much more accessible way to deal with these same methods through Java and javascript .(along with a few other features)

My largest existing hurdle is getting the history or state of each view to be stored in some kind of *history cache*. And when the back button is clicked, each of those view should be able to work as first rendered. Or, you could save the POST string somehow and just re-POST that string when the back button is clicked. I was chatting with my buddy Mert �aliskan, and he suggested that a custom ViewHandler may work or to use client side state saving, but I have not gotten around to testing those theories.

The g4jsf (Java) approach

G4jsf basically wraps GWT and makes it complementary to JSF. My only use for it as of now is back button support.

Currently, I have a standard facelets page with a datatable nested in the a4j:form which is nested in a gwt:page. All I did was run through this tutorial, created a basic widget that calls History.newItem('my history item string') during ...new AsyncCallback(){..., and now I have a history widget that writes to the browser's back button. My main question now is, what do I store as 'my history item string'? Should it be (as mentioned above) a POST string that I can call later, or do I store my rendered view somewhere?

The dojo.undo.browser (Javascript) approach

The dojo stuff is pretty straight forward. It obviously works in conjunction with dojo.io.bind, so my hopes were not very high when I started researching this. The results were suprising and gave me almost the same functionality as GWT. Another reason for going with this JSF/dojo approach is that g4jsf is not backwards compatible with JSF 1.1/Myfaces current version.

So, I am basically calling dojo.undo.browser.addToHistory(state); during my a4j:form onsubmit.

Just as in the examples here, I am using a state object that gets called and then queues/calls another function when the back button is clicked. I'm still stuck with the same scenario of how to store the rendered JSF view, but now atleast I have started the ball rolling, and have 2 totally different aproaches doing the same thing.

If anyone has done something similar, please chime in :)