Can you control browser back button using JSF faces-config navigation
Can you control browser back button using JSF faces-config navigation? When the back button is pressed on browser would like to use navigation like the following to control what page to display:
<navig开发者_Python百科ation-rule>
<from-view-id>/pageThree.xhtml</from-view-id>
<navigation-case>
<from-outcome>back</from-outcome>
<to-view-id>/pageOne.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
No, you can't. It's already not possible with HTML/JS, so JSF can't do much for you here.
Your best bet is to conditionally display the content of pageTwo.xhtml in pageOne.xhtml, based on some JS/ajax condition. This way there's no GET request on pageTwo.xhtml in the browser history.
Here's a basic kickoff example with plain JS:
<div id="one">
<h1>Page one</h1>
<p><a href="#" onclick="showPageTwo()">Go to page two</a></p>
</div>
<div id="two" style="display: none;">
<h1>Page two</h1>
<p><a href="pageThree.xhtml">Go to page three</a></p>
</div>
with
<script>
function showPageTwo() {
document.getElementById("one").style.display = 'none';
document.getElementById("two").style.display = 'block';
}
</script>
This is also easy with JSF 2.0 ajax and the rendered
attribute.
Here is one possible solution : dojo.back and jqueryTools
精彩评论