I believe it is more a JSF problem because I can even save the pdf  and open
the file outside the browser
I think it is more a JSF lifecycle problem the faces.responseComplete();
 is what displays the pdf


Martin Ahrer wrote:
> 
> Hi Joe, I'm using JSF+Birt myself in a project but I can't help in this
> special case but I suggest that you would rather get some quick response
> if you posted this to the birt newsgroup. I have experienced that they
> respond quite quickly!
> 
> 
> 
> Joe ONeil wrote:
>> 
>> I can create the pdf file and I can open the pdf file it but my browser
>> screen does not finish refreshing so end up with a white screen I create
>> the Birt engine in the application bean with has an application scope
>> I can create a HTML report and open it in a seperate browser window if I
>> have to but I would rather have a PDF This is the code I am using
>> 
>> ****application bean****
>> try{
>>      config = new EngineConfig();
>>      config.setEngineHome(
>> "C:\\birtruntime\\birt-runtime-2_2_0\\ReportEngine" );
>>      config.setLogConfig("c:/birt/logs", Level.FINE);
>>      Platform.startup( config );
>>      IReportEngineFactory factory = (IReportEngineFactory) Platform
>>      .createFactoryObject(  
>> IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
>>      engine = factory.createReportEngine( config );
>>      engine.changeLogLevel( Level.WARNING );
>>     }catch( Exception ex){
>>      ex.printStackTrace();
>>     }
>> I then have a action that uses the engine
>> public String birtReport2(){
>>              System.out.println("entering birtReport2");
>>              HashMap<String, Integer> parameters = new HashMap<String, 
>> Integer>();
>>               String name = "requestid";
>>                           Integer pvalue = new Integer(4);
>>                   parameters.put(name, 9667);
>>               FacesContext faces = FacesContext.getCurrentInstance();
>>              HttpServletResponse resp = (HttpServletResponse)
>> faces.getExternalContext
>>                                                                
>> ().getResponse();
>>              HttpServletRequest req=(HttpServletRequest)
>> faces.getExternalContext().getRequest();
>>              resp.setContentType( "application/pdf" ); 
>>              resp.setHeader ("Content-Disposition","attachment;
>> filename=/output.pdf");  
>>              ServletContext sc = req.getSession().getServletContext();
>>              PDFRenderContext renderContext = new PDFRenderContext();
>>              HashMap<String, PDFRenderContext> contextMap = new 
>> HashMap<String,  
>>                                                                              
>>                           
>> PDFRenderContext>();
>>               contextMap.put( EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT, 
>>                                                  renderContext );
>>                  IReportRunnable design;
>>               try
>>               {
>>                //Open report design
>>               design =
>> FacesUtils.getApplicationBean().getEngine().openReportDesign(sc.getRealPath
>>                                     
>> ("app/birt/compliancerecycle.rptdesign")); 
>>               //create task to run and render report
>>               IRunAndRenderTask task = 
>> FacesUtils.getApplicationBean().getEngine()
>>                                                                
>> .createRunAndRenderTask( design );  
>>               task.setAppContext( contextMap );
>>               //set output options
>>               PDFRenderOption options = new PDFRenderOption();
>>                
>> //options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
>>               options.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
>>               // options.setOutputFileName(filename);
>>              
>> //System.out.println("options.getOutputFileName()"+options.getOutputFileName());
>>               options.setOutputFormat("pdf");
>>                   options.setOutputStream(resp.getOutputStream());
>>                           task.setRenderOption(options);
>>               //run report
>>               task.run();
>>               task.close();
>>               faces.responseComplete();
>>               }catch (Exception e){
>>                                  e.printStackTrace();
>>               }
>>               System.out.println("leaving birtReport2");
>>              return "null";
>>      }
>> I have also tried it with the HTMLRenderContext and  HTMLRenderOption
>> with the same results
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JSF-render-BIRT-open-PDF-file-tf4238279.html#a12060728
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to