soufan

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            22 隨筆 :: 0 文章 :: 0 評論 :: 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中添加一個 action attribute? .然后你有一個actionListener?和 an action Attribute, 兩個都是可行的.

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

          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代碼中重定向一個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 閱讀(384) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 清河县| 汕尾市| 南安市| 凤冈县| 宜章县| 南投市| 武陟县| 炉霍县| 顺平县| 肥东县| 株洲县| 和静县| 武清区| 阿荣旗| 海淀区| 南木林县| 拜泉县| 固镇县| 顺义区| 台北县| 简阳市| 孝昌县| 廊坊市| 乌兰浩特市| 石城县| 丹东市| 富宁县| 高唐县| 桃园县| 涡阳县| 元谋县| 克什克腾旗| 霍城县| 东莞市| 泊头市| 浙江省| 博罗县| 六盘水市| 萨迦县| 临西县| 光泽县|