隨筆-112  評(píng)論-73  文章-0  trackbacks-0

          JSF 2.0 Navigation

           

          JSF 1.X 中使用導(dǎo)航需要在faces-config.xml 加入這樣的代碼:

           

          <navigation-rule>

            
          <navigation-case>

              
          <from-view-id>/pages/login.xhtml</from-view-id>

              
          <outcome>main</outcome>

              
          <to-view-id>/pages/main.xhtml</to-view-id>

            
          </navigation-case>

          </navigation-rule>

          JSF 2 中完全可以不用配置。


          <h:commandButton id="loginButton" 
            value
          ="#{msgs.loginButtonText}" action="main"/>

          點(diǎn)擊按鈕會(huì)轉(zhuǎn)到main.xhtmlJSF 會(huì)在當(dāng)前目錄中查找main.xhtml
          也可以使用絕對(duì)地址:
          <h:commandButton id="loginButton"

            value
          ="#{msgs.loginButtonText}"

            action
          ="/pages/main"/>
          
          
           

          默認(rèn)情況下JSF 會(huì)從一頁(yè)面forwards到另一個(gè)頁(yè)面。也可以使用redirect轉(zhuǎn)到另一個(gè)頁(yè)面。


          <h:commandButton id="loginButton"

            value
          ="#{msgs.loginButtonText}"

            action
          ="/pages/main?faces-redirect=true"/>

          相比 JSF1.2 要簡(jiǎn)單得多!

          posted on 2010-04-24 14:53 Libo 閱讀(1719) 評(píng)論(0)  編輯  收藏 所屬分類: JSF 2
          主站蜘蛛池模板: 五峰| 神木县| 石林| 临朐县| 道真| 同德县| 临泽县| 齐河县| 来凤县| 云浮市| 英山县| 江津市| 达拉特旗| 田阳县| 依兰县| 澎湖县| 和平县| 宜兰市| 武鸣县| 新巴尔虎左旗| 额尔古纳市| 泊头市| 天门市| 陆良县| 读书| 闽侯县| 当阳市| 策勒县| 保亭| 佛教| 贡山| 大同市| 关岭| 武乡县| 红桥区| 额敏县| 深水埗区| 岑巩县| 泰安市| 瓦房店市| 时尚|