2012-05-31 2 views
0

바이든 포틀렛을 처음 사용했습니다. Vaadin을 사용하여 몇 가지 Portlets을 개발했습니다. 이제 Vaadin 포틀릿에 Birt 보고서를 추가하고 싶지만,이 작업을 수행하는 방법이 없으므로이 작업에 도움이 될 수 있습니다. 또는이 도움말 문서가 있으면 정말 도움이 될 것입니다안녕하세요, 바이든 포틀릿에 버트 보고서를 추가하고 싶습니다.

미리 감사드립니다!

아자 드

답변

0

바아 진은 스윙과 거의 동일합니다. 그럼 내가 인터넷 http://www.eclipse.org/forums/index.php/mv/msg/119253/721257/의 코드를 발견하고 몇 가지 작은 적응 단지 angel이라는 창에서 실행하기 위해 만든 :

package com.example.testejanelas; 

import java.io.ByteArrayOutputStream; 
import java.net.URL; 
import java.net.URLClassLoader; 
import java.util.HashMap; 

import org.eclipse.birt.core.framework.Platform; 
import org.eclipse.birt.report.engine.api.EngineConfig; 
import org.eclipse.birt.report.engine.api.HTMLRenderOption; 
import org.eclipse.birt.report.engine.api.IReportEngine; 
import org.eclipse.birt.report.engine.api.IReportEngineFactory; 
import org.eclipse.birt.report.engine.api.IReportRunnable; 
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; 

import com.vaadin.ui.Label; 
import com.vaadin.ui.Window; 

public class ViewParaBIRT extends Window { 

private static final long serialVersionUID = 1L; 

IReportEngine engine = null; 
EngineConfig config = null; 
Label label; 

public ViewParaBIRT(){ 
    setSizeFull(); 
    startPlatform(); 
    System.out.println("Started"); 
    runReport(); 
    stopPlatform(); 
    System.out.println("Finished"); 
    center(); 
} 

public void runReport() { 
    try { 
     IReportRunnable design = null; 
     design = engine 
       .openReportDesign("D:\\workspace.carlos\\TesteJanelas\\src\\com\\example\\birt\\new_report.rptdesign"); 
     IRunAndRenderTask task = engine.createRunAndRenderTask(design); 
     HTMLRenderOption options = new HTMLRenderOption(); 
     ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
     bos.toString("ISO-8859-1"); 
     options.setOutputStream(bos); 
     options.setOutputFormat("html"); 
     options.setEmbeddable(true); 
     task.setRenderOption(options); 
     task.run(); 
     task.close(); 
     label = new Label(bos.toString(),Label.CONTENT_XHTML); 
     addComponent(label); 
     System.out.println("Finished Gen"); 
    } catch (Exception ex) { 
     ex.printStackTrace(); 
    } 
} 

public void startPlatform() { 
    try { 
     config = new EngineConfig(); 
     HashMap context = new HashMap(); 
     URLClassLoader cl = (URLClassLoader) TestBirtViewer.class 
       .getClassLoader(); 
     URL[] myurls = cl.getURLs(); 
     Class cl1 = cl.loadClass("com.mysql.jdbc.Driver"); 
     context.put("PARENT_CLASSLOADER", cl); 
     config.setAppContext(context); 
     Platform.startup(config); 
     IReportEngineFactory factory = (IReportEngineFactory) Platform 
       .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY); 
     engine = factory.createReportEngine(config); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 

public void stopPlatform() { 
    engine.destroy(); 
    Platform.shutdown(); 
} 

} 
+0

'TestBirtViewer.class' 무엇입니까? – Pere

관련 문제