在backing bean中添加JavaScript代码输出到客户端

FacesContext ctx = FacesContext.getCurrentInstance();    
         String contentType = "text/html;charset=utf-8";    
         HttpServletResponse response = (HttpServletResponse) ctx    
                 .getExternalContext().getResponse();    
         response.setContentType(contentType);    
         ServletOutputStream out = response.getOutputStream();    
         StringBuffer buf = new StringBuffer();    
buf.append("<script type=\"text/javascript\">\n");    
         buf.append("<!--\n");    
        // 弹出模式窗口    
         buf.append("var rtn=window.showModalDialog('");    
.....    
.    
.    

 

你可能感兴趣的:(JavaScript,html,bean)