JSF Back Button
13,727
To the point: just remember the request URL or the JSF viewId of the previous page so that you can use it in the href or value of the output/commandlink. There are several ways to achieve it, depending on how you're actually navigating through the pages and how "jsfish" you want to achieve it. You could pass it as a request parameter by f:param
in h:outputLink
, or you could set it as a bean property by f:setPropertyActionListener
in h:commandLink
, or you could create a PhaseListener
which remembers the viewId
and make use of navigation cases, or you could grab the -much less reliable- JavaScript history.go()
function.
Author by
DD.
Updated on June 04, 2022Comments
-
DD. almost 2 years
How do I make a link which navigates the user back one page (i.e. same as clicking browser back)?
Thanks.
-
user1568901 over 13 yearsI'm missing something here. Trying to implement the history.go() method of going back (because I have to go back to non-JSF pages too), but the javascript doesn't run. immediate=true and onclick of history.go(-1). The onclick javascript never gets called, the page refreshes instead.
-
BalusC over 13 years@Brian: Press
Ask Question
button if you stucks. Post an SSCCE if you can. -
user1568901 over 13 yearsNevermind, I got it. Needed to set "type=button" as well...
-
Thang Pham almost 12 yearsBalusC: do you think you can elaborate the use of
PhaseListener
? Maybe add a bit more code into it?