How do I make a link which navigates the user back one page (i.e. same as clicking browser back)?
Thanks.
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.
精彩评论