back commandbutton in jsf

I use a h:commandLink with attribute onclick="history.go(-1)" in this case. It works universally.


My first idea :

on every

<h:commandLink .....>

and etc; store the navigation string in a bean, or even a stack, and then the back button can retrieve it and just return that as per faces-config.xml

Second idea.

But on reflection you should override or use a filter to intercept the navigation commands and push them onto a stack. Then the back button can just pop the navigation off and away you go.


You can use:

<p:commandButton onclick="window.history.back();"/>

That instruction do the same as onclick="history.go(-1)" which alexmeia has said.