Jump to: navigation, search

Difference between revisions of "RCP Example (BIRT) 2.1"

(Comments)
(Comments)
 
(2 intermediate revisions by 2 users not shown)
Line 59: Line 59:
 
  //                  "run");
 
  //                  "run");
  
== Comments ==
+
== Download Examples ==
 
Please enter comments below by selecting the edit icon to the right.
 
Please enter comments below by selecting the edit icon to the right.
 
You will need a Bugzilla account to add comments.
 
You will need a Bugzilla account to add comments.
Line 65: Line 65:
 
----
 
----
 
Example of using the Report Viewer in an RCP application.
 
Example of using the Report Viewer in an RCP application.
[http://download.eclipse.org/birt/downloads/examples/integrating/rcp/rcpviewer.zip BIRT RCP Viewer]
+
[http://www.birt-exchange.org/org/devshare/deploying-birt-reports/1344-eclipsecon-2011-api-examples/ BIRT RCP Viewer]<br>
 
+
Look at the org.eclipse.birt.examples.rcpviewer example in the download. 
 
+
Product Configuration file:
 +
[http://www.birt-exchange.org/org/devshare/deploying-birt-reports/1194-eclipse-product-configuration-file-for-webviewer-in-rcp/ Viewer Product Configuration File]<br>
 
Example of using the Report Engine in an RCP application.
 
Example of using the Report Engine in an RCP application.
[http://download.eclipse.org/birt/downloads/examples/integrating/rcp/rcpengine.zip BIRT RCP Engine]
+
[http://www.birt-exchange.org/org/devshare/deploying-birt-reports/1344-eclipsecon-2011-api-examples/ BIRT RCP Engine]<br>
 
+
Look at the org.eclipse.birt.examples.rcpengine example in the download.
  
 
== BIRT 2.3.2 Example Using the Viewer plugin ==
 
== BIRT 2.3.2 Example Using the Viewer plugin ==
Line 169: Line 170:
 
Hy,
 
Hy,
 
I'm not able compile the project. The error log is:
 
I'm not able compile the project. The error log is:
   Cannot nest 'C:[...]/eclipse/plugins/org.eclipse.birt.report.viewer_2.3.2.r232_20090212/birt/WEB-INF/classes' inside library '[...]/eclipse/plugins/org.eclipse.birt.report.viewer_2.3.2.r232_20090212'
+
   Cannot nest 'C:[...]/eclipse/plugins/org.eclipse.birt.report.viewer_2.3.2.r232_20090212/birt/WEB-INF/classes' inside library  
 +
  '[...]/eclipse/plugins/org.eclipse.birt.report.viewer_2.3.2.r232_20090212'
 
Which configuration did you have (jre, eclipse, birt ...)?
 
Which configuration did you have (jre, eclipse, birt ...)?
  

Latest revision as of 01:18, 20 April 2011

< To: Integration Examples (BIRT)

RCP Example

This example explains how to deploy the BIRT Viewer within an RCP application.


Add comments at the bottom of the example.

BIRT Report Engine API Return to the BIRT Report Engine API examples

If using the Report Engine API plugin in an RCP application, add code similar to the following to set the APPCONTEXT_CLASSLOADER_KEY.


          config = new EngineConfig();
          HashMap hm = config.getAppContext();
          hm.put( EngineConstants.APPCONTEXT_CLASSLOADER_KEY, MyClass.class.getClassLoader());
          config.setAppContext(hm); 

Setup

1. Add the BIRT Viewer plug-in to your project dependencies. Runtime dependencies will be determined by what options your reports use. For example if you use a JDBC data source, then the JDBC plug-in will be required at runtime.

Example.jpg

2. Call WebViewer.display from your code. Use one of the following options. Note that browser will need to be defined as an org.eclipse.swt.browser.Browser.

Code Snippet

//option 1 display with no parameters in url.  
//Parameter box will display if
//required in a seperate window.  
//This uses the /run mapping
//WebViewer.display(reportName , 
//                  WebViewer.HTML, 
//                  false);	
//option 2 display BIRT Viewer in sepearate 
//Browser with /frameset mapping
//WebViewer.display(reportName , 
//                  WebViewer.HTML, 
//                  true);
//option 3 display in SWT Browser 
//using /frameset mapping.
//WebViewer.display(reportName, 
//                  WebViewer.HTML, 
//                  browser, 
//                  "frameset");
//option 4 display in SWT Browser
// using /run mapping.
//WebViewer.display(reportName, 
//                  WebViewer.HTML, 
//                  browser,
//                  "run");

Download Examples

Please enter comments below by selecting the edit icon to the right. You will need a Bugzilla account to add comments.


Example of using the Report Viewer in an RCP application. BIRT RCP Viewer
Look at the org.eclipse.birt.examples.rcpviewer example in the download. Product Configuration file: Viewer Product Configuration File
Example of using the Report Engine in an RCP application. BIRT RCP Engine
Look at the org.eclipse.birt.examples.rcpengine example in the download.

BIRT 2.3.2 Example Using the Viewer plugin

//Most Common WebViwer Options shown below
		
//Use this code to set your own app context
//Which allows you to set the parent classloader and add to the classpath
//You can also add your own specific variables so reports can access the values like
//reportContext.getAppContext().get("MyObject");

/* use a class similar to the following:
package org.eclipse.birt.examples.rcpviewer;
import java.util.Map;
import org.eclipse.birt.report.viewer.api.AppContextExtension;
public class MyAppContext extends AppContextExtension{
   public Map getAppContext(Map appContext) {
      Map hm = super.getAppContext(appContext);
      hm.put("PARENT_CLASSLOADER", PreviewBirtAction.class.getClassLoader());
      hm.put("webapplication.projectclasspath", "c:/jars/mjo.jar");  
      return hm;			
   }
   public String getName() {
             return "MyAppContext";
   }
}
 Make sure to add the following to your plugin.xml
 <extension
      point="org.eclipse.birt.report.viewer.appcontext">
      <appcontext
            class="org.eclipse.birt.examples.rcpviewer.MyAppContext">
      </appcontext>
 </extension>
*/
ViewerPlugin.getDefault( ).getPluginPreferences( ).setValue("APPCONTEXT_EXTENSION_KEY", "MyAppContext");
			
			
			
 //Use this approach to load report from bundle
 //Bundle bundle = org.eclipse.core.runtime.Platform.getBundle("testdata"); 
 //URL url = FileLocator.find(bundle, new Path("/reports/myreport.rptdesign"), null);
 //String rpt = FileLocator.toFileURL(url).getPath();
 
 //In all cases where a separate browser window is used the WebViewer Class checks for
 //external browser preference setting
 //boolean useExternal = ViewerPlugin.getDefault( )
 //.getPluginPreferences( )
 //.getBoolean( BrowserManager.ALWAYS_EXTERNAL_BROWSER_KEY );

			
//option 1 display with no parameters in url.  Parameter box will display if
//required in a seperate window.  This uses the /preview mapping
//WebViewer.startup();
//WebViewer.display(reportName , WebViewer.PDF);	
			
//option 2 display BIRT Viewer in sepearate Browser with /frameset mapping
//allow page (third parameter determines if HTLM pagination is allowed)
//true use frameset else use preview mapping
//WebViewer.startup();
//WebViewer.display(reportName , WebViewer.HTML, true);
			
//option 3 launch in separate browswer window
//HashMap myparms = new HashMap();
//myparms.put("SERVLET_NAME_KEY", "frameset");
//myparms.put("FORMAT_KEY", "html");
//myparms.put("RESOURCE_FOLDER_KEY", "c:/myresources");
//myparms.put("ALLOW_PAGE", false);
//myparms.put("MAX_ROWS_KEY", "500");			
//WebViewer.display("viewer", reportName , myparms);
			

//option 4 display in SWT Browser using /frameset mapping.
HashMap myparms = new HashMap();
myparms.put("SERVLET_NAME_KEY", "frameset");
myparms.put("FORMAT_KEY", "html");
//myparms.put("RESOURCE_FOLDER_KEY", "c:/myresources");
//myparms.put("ALLOW_PAGE", false);
//myparms.put("MAX_ROWS_KEY", "500");
WebViewer.display(reportName, browser, myparms);
			
//option 5 display with parameters encoded in the URL
//Check the source for the viewer plugin to add a createURL function
//Start with this and add the appropriate parameters as defined on the example J2EE Viewer page
//WebViewer.startup();
//String myurl = "http://" + WebappAccessor.getHost( ) + ":" 
//+ WebappAccessor.getPort( "viewer" )
//+ "/viewer/";
//browser.setUrl(myurl);

User Comments

This is a great example but it took me a few tries to make it work.

After importing the BIRT RCP Viewer example project, I had to create a new Run Configuration, select the Plug-ins tab, and then press the Select All button. After that, the example ran perfectly. --Vdodson.actuate.com 12:36, 8 June 2007 (EDT)


Comments

Hy, I'm not able compile the project. The error log is:

  Cannot nest 'C:[...]/eclipse/plugins/org.eclipse.birt.report.viewer_2.3.2.r232_20090212/birt/WEB-INF/classes' inside library 
  '[...]/eclipse/plugins/org.eclipse.birt.report.viewer_2.3.2.r232_20090212'

Which configuration did you have (jre, eclipse, birt ...)?