`

JSFUtils打开新窗口

    博客分类:
  • ADF
 
阅读更多

在ADF的MB中直接传参跳转到页面html:  

                 

String path = "pages/xtgl/utils/showPDF.html?fjzj=" + fjzj;                   

JSFUtils.openNewPage(JSFUtils.pageUrl(path));

 

    /**
     * 新url
     * @param view
     * @return null
     * */
    public static String pageUrl(String view){
        FacesContext facesContext = getFacesContext();
        ExternalContext externalContext = facesContext.getExternalContext();
        String url =
            ((HttpServletRequest)externalContext.getRequest()).getRequestURL().toString();
        StringBuffer newUrlBuffer = new StringBuffer();
        newUrlBuffer.append(url.substring(0, url.lastIndexOf("faces/")));
        newUrlBuffer.append(view);
        return newUrlBuffer.toString();
    }

 

    /**
     * @function 打开新的页面窗口。
     * @param view
     * @return null
     */
    public static void openNewPage(String view) {
        FacesContext context = FacesContext.getCurrentInstance();
        StringBuilder script = new StringBuilder().append("window.open('").append(view).append("', '_blank', 'toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,width=800,height=600,top=100,left=100', true);");        
        ExtendedRenderKitService erks =
            Service.getService(context.getRenderKit(),
                               ExtendedRenderKitService.class);
        erks.addScript(context, script.toString());
        
//        ExternalContext ectx = context.getExternalContext();
//        try {
//            ectx.redirect(url);  //重定向
//        } catch (IOException e) {
//            e.fillInStackTrace();
//        }
    }

html页面中引入js也需要按照一定的顺序(先引入jQuery):

 <script language="JavaScript" src="../../../js/jquery-1.7.2.js"></script>
 <script language="JavaScript" src="../../../js/flexpaper/flexpaper.js"></script>
 <script language="JavaScript" src="../../../js/flexpaper/flexpaper_handlers.js"></script> 

 

--摘自档案管理系统的附件预览

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics