【问题标题】:Can you control browser back button using JSF faces-config navigation您可以使用 JSF faces-config 导航控制浏览器后退按钮吗
【发布时间】:2010-12-08 21:15:06
【问题描述】:

你可以使用 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>

【问题讨论】:

    标签: jsf back-button


    【解决方案1】:

    不,你不能。 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>
    

    <script>
        function showPageTwo() {
            document.getElementById("one").style.display = 'none';
            document.getElementById("two").style.display = 'block';
        }
    </script>
    

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-27
        • 1970-01-01
        • 2010-10-28
        相关资源
        最近更新 更多