Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Adding an Object to the Application Context for the Viewer (BIRT)"

(Description)
(Description)
 
Line 11: Line 11:
 
[https://bugs.eclipse.org/bugs/attachment.cgi?id=67552 Example Report]  
 
[https://bugs.eclipse.org/bugs/attachment.cgi?id=67552 Example Report]  
 
== Description==  
 
== Description==  
To add a specific object to the Application Context for use within the viewer requires that you set some request attributes before calling the viewer.  Specifically these are the AppContextKey adn AppContextValue attributes.  The AppContextKey is the name that will be used to reference the object within the report.  The AppContextValue will be the object that gets added.  Presented below is an example JSP page that adds these attributes to the request.  Notice we are just using a String object, but this could be any object in your application.
+
To add a specific object to the Application Context for use within the viewer requires that you set some request attributes before calling the viewer.  Specifically these are the AppContextKey adn AppContextValue attributes.  The AppContextKey is the name that will be used to reference the object within the report.  The AppContextValue will be the object that gets added.  Presented below is an example JSP page that adds these attributes to the session.  Notice we are just using a String object, but this could be any object in your application.
  
 
  <%
 
  <%
 
  java.lang.String teststr = "MyTest";
 
  java.lang.String teststr = "MyTest";
  request.setAttribute( "AppContextKey", teststr  );
+
  session.setAttribute( "AppContextKey", teststr  );
 
  java.lang.String stringObj = "This test my Application Context From the Viewer";
 
  java.lang.String stringObj = "This test my Application Context From the Viewer";
  request.setAttribute( "AppContextValue", stringObj );
+
  session.setAttribute( "AppContextValue", stringObj );
   
+
  String redirectURL = "http://localhost:8080/2.5.0/frameset?__report=AppContext.rptdesign";
%>
+
response.sendRedirect(redirectURL);
<jsp:forward page= "<%=  "/run?__report=AppContext.rptdesign" %>"/>
+
%>  
  
Using the frameset mapping has an issue.  See [https://bugs.eclipse.org/bugs/show_bug.cgi?id=213503 bug 213503]
 
  
  

Latest revision as of 19:22, 29 July 2009

< To: Report Developer Examples (BIRT)
This example is Bugzilla ID 187417. If you would like to contribute an example see the example contribution guidelines.

Introduction

BIRT uses an Application Context Map to store values and object for use in all phases of report generation and presentation. Objects in the Application Context can be referenced from Script, the Expression Builder, in the ODA layer, etc. Modifying the Application Context can be done using the APIs. It can also be done using the Web Viewer. This example demonstrates adding an Object to the Application Context for the Viewer.

BIRT Version Compatibility

This example was built and tested with BIRT 2.2 M6.

Example Files

Add a URL to your bugzilla attachment. eg. Example Report

Description

To add a specific object to the Application Context for use within the viewer requires that you set some request attributes before calling the viewer. Specifically these are the AppContextKey adn AppContextValue attributes. The AppContextKey is the name that will be used to reference the object within the report. The AppContextValue will be the object that gets added. Presented below is an example JSP page that adds these attributes to the session. Notice we are just using a String object, but this could be any object in your application.

<%
java.lang.String teststr = "MyTest";
session.setAttribute( "AppContextKey", teststr  );
java.lang.String stringObj = "This test my Application Context From the Viewer";
session.setAttribute( "AppContextValue", stringObj );
String redirectURL = "http://localhost:8080/2.5.0/frameset?__report=AppContext.rptdesign";
response.sendRedirect(redirectURL);
%> 


The AppContext.rptdesign report can now access the object (stringObj) in an expression like:

MyTest.toString();

and the value returned will be:

"This test my Application Context From the Viewer"

Comments

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


Copyright © Eclipse Foundation, Inc. All Rights Reserved.