I used rsh ( http://code.google.com/p/reallysimplehistory/ )
and it works in firefox, but not in IE7
in <HEAD> :
<script type="text/javascript" src="../javascript/json2005.js"></script>
<script type="text/javascript" src="../javascript/rsh.compressed.js"></script>
<script type="text/javascript">
window.dhtmlHistory.create({
toJSON: function(o)
{ return JSON.stringify(o);}
, fromJSON: function(s)
{ return JSON.parse(s);}
});
var historyChange = function(newLocation, historyData)
{
document.getElementById("headerForm:historyHiddenData").value = newLocation;
iceSubmitPartial(document.getElementById("headerForm"),document.getElementById("headerForm:HistoryBtn"),MouseEvent.CLICK);
}
historyActionListener = function (location, action)
{ dhtmlHistory.add(location, action); }
window.onload = function()
{
dhtmlHistory.initialize();
dhtmlHistory.addListener(historyChange);
}
;
</script>
hidden components in the page :
<!-- hidden browser navigation -->
<ice:commandButton id="HistoryBtn" value="" action="HISTORY" visible="false"/>
<ice:inputHidden id="historyHiddenData" value="" />
I have JSf a navigation handler :
public void handleNavigation(FacesContext facesContext, String actionMethod, String actionName) {
HtmlInputHidden input = ((HtmlInputHidden) facesContext.getViewRoot().findComponent(
"headerForm:historyHiddenData"));
if (input != null) {
String value = input.getValue().toString();
String viewId = value;
if ((value != null) && (value != ""))
{
UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext,
viewId);
facesContext.setViewRoot(root);
}
}
I save the history only when I click on a menuitem :
MenuItem menuItem = new MenuItem();
String navUrl = getNavigationUrl(action);
if (navUrl != null)
menuItem.setOnclick("historyActionListener('" + navUrl + "' , '"
+ action + "')");
function getNavigationUrl returns the navigation url associated with this outcome.
Ok in Firefox 3, but no javascript errors in IE7 and it doesn't works.
I would like to add that the approach described by this article http://www.onjava.com/pub/a/onjava/2005/10/26/ajax-handling-bookmarks-and-back-button.html
works with ICEFaces in Internet explorer 7.0. But when i tryed to use it with mozilla it couldn't find the submit javascript of the form. If requested I can give source code to test.