views:

1076

answers:

3

how would one implement a back-button as a commandbutton that works universally? with back button i don't mean the browser-button, but rather a button that sits somewhere on the page. it is not always possible to use the Post-redirect-get pattern.

its quite impractial to pass around the information on every single where the button should point to.

is there maybe a reserved keyword for a navigation rule that points to the last navigation rule applied?

+2  A: 

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.

Martlark
+2  A: 

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

alexmeia
Was hoping this would help me out, but doesn't appear to work with h:commandButton. :-(
Brian Knoblauch
Do you really need to use a jsf tag for this? If not, try with <input type="button" onclick="history.go(-1)" />. It will work.
alexmeia
A: 

I would store the navigation string in a stack datatype and you use the stack.peek() to show which is the site behind you, and when its clicked you fire an action event that triggers the stack.pop()

ChrisAD