Trebla
Trebla

Reputation: 1174

BIRT - Dynamic Master Page based on runtime data

I'm trying to deploy a single report which will be used by multiple organizations. Each of these organizations wants their logos on the report to display when:

logged_in_user.org_id = 'xxx' or 'yyy'.

I've created a nice library with multiple master pages holding the different logos. What I'm unable to determine is if there's anyway to dynamically choose which master page to apply to the report at run time after I've loaded the user data, perhaps in the initialize() method for the page.

I figured out how to get a handle on the master page using:

reportContext.getDesignHandle().findMasterPage("org_X_Master")

But I'm stymied trying to figure out how to set this as the master page for the report. Any help would be appreciated.

Upvotes: 2

Views: 1358

Answers (1)

hvb
hvb

Reputation: 2668

We had a very similar problem. There may be other solutions, but here's how we solved it:

Move the whole content of your report (say, reportX.rptdesign) into a library (say, reportX.rptlibrary). Then create two blank reports reportXxxx.rptdesign and reportXyyy.rptdesign, with different master pages.

Drag the complete layout from reportX.rptlibrary into reportXxxx and into reportXyyy.

Only the Javascript code in the initialize event has to be duplicated this way, but you could even move it to an external *.js library.

Note: This is not an answer to your exact question, because you need to call either reportXxxx or reportXyyy from your application (so the decision happens before calling the report).

Upvotes: 1

Related Questions