jQuery in Action, 3rd edition
The moose likes JSF and the fly likes Going back to the previous page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Going back to the previous page" Watch "Going back to the previous page" New topic

Going back to the previous page

Ramesh Etta
Ranch Hand

Joined: Sep 18, 2007
Posts: 47

I want to place a BACK button in my jsf page that will take to the previous page what i had viewed.

Is there any tags or code that will do this.
please send me the code or an example

Thanks and Regards
Alberto Dousdebes

Joined: Sep 02, 2008
Posts: 22
U can use a navigation case. In faces-config define a new one.

page 1 <------- "back" ------------ page 2

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

You can simply use javascript for this. history.forward(-1)

Please google it I m not sure about this. Give this on onclick event.

My Blog SCJP 5 SCWCD 5
Ketan Jambhekar
Ranch Hand

Joined: Mar 26, 2007
Posts: 37
You can try with the UIViewRoot object.
You can store the UIViewRoot for the first page in a variable and then try setting it again in Context when the back button is called.
Once set you can call the renderResponse from Context.

To get the UIViewRoot :

when back button is called :

a phil

Joined: Nov 11, 2008
Posts: 9
Hi ketan,

that was a simple and sweet trick. i liked it.
Ramesh Etta
Ranch Hand

Joined: Sep 18, 2007
Posts: 47
Thanks for your reply.
My requirement is i am calling a jsp from a subView and in the called jsp i need to place the back button which will take to the subView which is previews before.

I know to set the viewId, but how to set the subViewId.

Please reply, as it is an urgent requirement.

Consider Paul's rocket mass heater.
subject: Going back to the previous page
It's not a secret anymore!