soufan

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            22 隨筆 :: 0 文章 :: 0 評(píng)論 :: 0 Trackbacks
          How to change destination JSP from within RENDER_RESPONSE phase?

          public?void?
          beforePhase ( PhaseEvent?arg0 )?
          {
          if ( arg0.getPhaseId () ==?PhaseId.RENDER_RESPONSE )
          {
          ?? FacesContext?facesContext?=?arg0.getFacesContext () ;
          ?? ViewHandler?vh??=?facesContext.getApplication () .getViewHandler () ;
          ?? UIViewRoot?newRoot?=?vh.createView ( facesContext,? "/yourNew.jsp" ) ;
          ?? facesContext.setViewRoot ( newRoot ) ;
          }



          How to foward to another JSP from an actionListener ActionEvent

          有兩種方法:

          簡單的方法是在commandlink中添加一個(gè) action attribute? .然后你有一個(gè)actionListener?和 an action Attribute, 兩個(gè)都是可行的.

          但是你還可以使用下面的代碼:

          String?viewId?=?"/edit.jsp";
          FacesContext?context?=?FacesContext.getCurrentInstance();
          UIViewRoot?view?=?context.getApplication().getViewHandler().createView(context,?viewId);
          view.setViewId(viewId);
          context.setViewRoot(view);
          context.renderResponse();


          如何從java代碼中重定向一個(gè)JSF頁面

          示例代碼如下:

          public?static?void?redirectPage(String?szPage)
          {
          ?FacesContext?context?=?FacesContext.getCurrentInstance();
          ?javax.faces.application.Application?app?=?context.getApplication();
          ?UIViewRoot?view?=?app.getViewHandler().createView(context,?szPage);
          ?context.setViewRoot(view);
          ?context.renderResponse();
          }
          posted on 2006-12-19 16:10 soufan 閱讀(383) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 乐至县| 凤冈县| 鲁山县| 留坝县| 北海市| 搜索| 清新县| 周至县| 科尔| SHOW| 遵化市| 石河子市| 壶关县| 桃园县| 黑水县| 沾化县| 灯塔市| 鄯善县| 乡城县| 定南县| 玉田县| 清远市| 东港市| 乐至县| 清苑县| 汨罗市| 沿河| 醴陵市| 定兴县| 桂阳县| 夏河县| 吕梁市| 莱州市| 隆昌县| 宜兰市| 甘孜| 龙江县| 高邮市| 分宜县| 海宁市| 梓潼县|