Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Duplicate reports
Duplicate reports [message #806656] Sat, 25 February 2012 08:55 Go to next message
Timothy Vogel is currently offline Timothy VogelFriend
Messages: 82
Registered: July 2009
Member
Issue
I have an RCP application that uses BIRT for reporting. When I create a report on a model object the first time the object's data is correctly shown. When I create a report on a different model object the first object's data is displayed. Each report is opened in a different page within the application.

Question
How do I clear out the previous application context so that the 2nd object's data is displayed?

Setup / Background
- The report template is scripted from a Java object.
- The Java object is passed in via an application context created in the manifest
- The following code is called for each report
WindingCardAppContext reportData = new WindingCardAppContext();

// display the PDF allowing the user to print if desired
Browser browser = new Browser(form.getBody(), SWT.NONE);
Map<String, String> params = new HashMap<String, String>();
params.put(WebViewer.SERVLET_NAME_KEY, WebViewer.VIEWER_FRAMESET);
params.put(WebViewer.FORMAT_KEY, WebViewer.HTML);
Preferences pref = ViewerPlugin.getDefault().getPluginPreferences();
pref.setValue(WebViewer.APPCONTEXT_EXTENSION_KEY, "windingcard.appcontext");
reportData.setResult(selectedResult);
reportData.setMotor(editor.getMotor());
reportData.setCustomer(this.customer);
WebViewer.display(this.reportTemplate, browser, params);
form.getBody().layout();

Re: Duplicate reports [message #808479 is a reply to message #806656] Mon, 27 February 2012 20:42 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Instead of recreating the app context class every time why not just
create one and add some setters for result, motor and customer? Then in
the getAppContext method re-query for the results. If you do this
approach I assume your app context class will be static.

Another approach is the pass the result, motor and customer to the
report as url parameters and let the report create the reportData
object. You do this using the EMITTER_OPTIONS key:

HashMap myparms = new HashMap();
HashMap emitmap = 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("SHOW_PARAMETER_PAGE", "false");
emitmap.put("myurlparameter", "this is a test");
myparms.put("EMITTER_OPTIONS_KEY", emitmap);
WebViewer.display(rpt, browser, myparms);

In script you can then retrieve the url parameter like:

reportContext.getHttpServletRequest().getParameter("myurlparameter");

Jason

On 2/25/2012 3:55 AM, Timothy Vogel wrote:
> Issue
> I have an RCP application that uses BIRT for reporting. When I create a
> report on a model object the first time the object's data is correctly
> shown. When I create a report on a different model object the first
> object's data is displayed. Each report is opened in a different page
> within the application.
>
> Question
> How do I clear out the previous application context so that the 2nd
> object's data is displayed?
>
> Setup / Background
> - The report template is scripted from a Java object. - The Java object
> is passed in via an application context created in the manifest
> - The following code is called for each report
>
> WindingCardAppContext reportData = new WindingCardAppContext();
>
> // display the PDF allowing the user to print if desired
> Browser browser = new Browser(form.getBody(), SWT.NONE);
> Map<String, String> params = new HashMap<String, String>();
> params.put(WebViewer.SERVLET_NAME_KEY, WebViewer.VIEWER_FRAMESET);
> params.put(WebViewer.FORMAT_KEY, WebViewer.HTML);
> Preferences pref = ViewerPlugin.getDefault().getPluginPreferences();
> pref.setValue(WebViewer.APPCONTEXT_EXTENSION_KEY,
> "windingcard.appcontext");
> reportData.setResult(selectedResult);
> reportData.setMotor(editor.getMotor());
> reportData.setCustomer(this.customer);
> WebViewer.display(this.reportTemplate, browser, params);
> form.getBody().layout();
>
>
Re: Duplicate reports [message #808588 is a reply to message #806656] Mon, 27 February 2012 23:34 Go to previous message
Timothy Vogel is currently offline Timothy VogelFriend
Messages: 82
Registered: July 2009
Member
Jason,
Thanks for the suggestions.

I found the error in my code, nothing to do with Birt. It was a bonehead mistake. Embarrassed In the getAppContext, instead of adding my parameters to the Map passed in, I created a new one. As soon as I added my parameters to the one passed in, everything started working correctly.
Previous Topic:BIRT Viewer license
Next Topic:.odp and .odt formats gives exception
Goto Forum:
  


Current Time: Tue Apr 23 07:48:42 GMT 2024

Powered by FUDForum. Page generated in 0.02772 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top