您可以使用 JSF faces-config 导航控制浏览器后退按钮吗

发布于 2024-10-06 16:50:19 字数 372 浏览 0 评论 0原文

您可以使用 JSF faces-config 导航控制浏览器后退按钮吗?当在浏览器上按下后退按钮时,希望使用如下所示的导航来控制要显示的页面:

 <navigation-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>

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:

 <navigation-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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ˇ宁静的妩媚 2024-10-13 16:50:19

不,你不能。 HTML/JS 已经不可能做到这一点,因此 JSF 在这里无法为您做太多事情。

最好的选择是根据某些 JS/ajax 条件,有条件地在 pageOne.xhtml 中显示 pageTwo.xhtml 的内容。这样浏览器历史记录中就没有针对 pageTwo.xhtml 的 GET 请求。

下面是一个使用普通 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>

使用 JSF 2.0 ajax 和 rendered 属性这也很容易。

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.

你怎么敢 2024-10-13 16:50:19

这是一种可能的解决方案: dojo.backjqueryTools

Here is one possible solution : dojo.back and jqueryTools

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文