Jump to content
We've recently updated our Privacy Statement, available here ×

subreport setup


stejim0

Recommended Posts

Hi, new to this so apologies in advance.

 

I have been using jasperintelligence with some success. Now I am trying to upload my first report containing 2 sub-reports. Does anyone have documentation on what is needed? In iReports do I need to define the sub-report path a certain way? I currently have the path set to $P{SUBREPORT_DIR} + "RepInvs2.jasper" with the $P{SUBREPORT_DIR} set to ".\"

 

Do I need to move the RepInvs2.jasper file manually to the web server? If so where do I put it?

 

Should I just need to upload the .jrxml file and that will be enough? Tried that but maybe something else is wrong.

 

Do I need to create a new reportunit for the sub-report? Tried that, got the sub-report to run but maybe something else is wrong?

 

A quick response would appreciated as i'm just a tad behind on this one.

 

Thanks,

 

Jim

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

A subreport can be included in a report unit by uploading the *.jrxml file as a local resource. The subreport should then be referred in the master report using a subreport expression such as

Code:
<subreportExpression>"repo:LocalSubreport"</subreportExpression>

where "LocalSubreport" is the name of the local resource in the report unit.

 

HTH,

Lucian

Link to comment
Share on other sites

  • 2 years later...

Hi,

Can you please tell me the steps to link a subreport to the main report on the Jasper Server? I was able to do the same on iReport tool.

I tried the solution given by 'lucianc' but no luck. How do add the Subreport, with extension OR without extention?

Thanks,

Kiran

Link to comment
Share on other sites

SImple create the master and sub-report in iReport. Before upload both report to JS, please change the path in main-report as per Lucianc reply. repo:<resource name> not necessary the actual file name. Its the name (resource ID)  that you difine when you upload it

Link to comment
Share on other sites

  • 5 weeks later...

Hi,

 

I tried the trick suggested by Teodor (Post #7491) and it did work.  Thanks!

 

To ease the testing on both iReport and JasperServer, I use this idiom for the subreport expression (since they expect different things in the two settings: a local file name like "foo.jasper" and a JS "Name" for the uploaded JRXML file like "foo"

 

1. I defined a Boolean parameter isOnJS ("is running on a jasperserver).  The value will be default to "new Boolean(false)" and "new Boolean(true)", respectively, for the two settings.

 

2. I also defined a String parameter subRptExt.  The value will be default to this expression:

 

$P{isOnJS}.booleanValue() ? "" : ".jasper"

 

3. The parameter $P{SUBREPORT-DIR} is defined to be

 

$P{isOnJS}.booleanValue() ? "repo:" : "C:\\path\\to\\local-dir\\"

 

4. The subreport expression for the subreport is defined to be

 

$P{SUBREPORT_DIR} + "foo" + $P{subRptExt}

 

In other words, when run in iReport and in JasperServer, the subreport expression will be expanded to these two names respectively:

 

"C:\\path\\to\\local-dir\\foo.jasper"

 

"repo:foo"

 

5. When uploading the subreport's JRXML file (e.g. foo.jrxml) to JS, make sure to name it exactly the same as the JASPER file (used in Step 3), except that the extension ".jasper" has to be dropped.  E.g. "foo"

 

(I could have done away the parameter "subRptExt" if I am willing to name a JS name for a JRXML file with a suffix ".jasper", but I would rather not at least for now)

 

So this is working, but a bit tedious.  Are there easier and more elegant solution?

 

Specifically, is there already a parameter that functions like my "isOnJS" ?

 

Thanks!

Link to comment
Share on other sites

  • 4 weeks later...
Thank you for your great idea! I wish this would be something more automatic, especially if uploading from the plugin in iReport, it seems that it is something that should just be done as the report goes to or from the server rather transparently.
Link to comment
Share on other sites

leeyuiwah
Wrote:

Specifically, is there already a parameter that functions like my "isOnJS" ?

There is no such built in parameter, but you could try a parameter like below.

Regards,

Lucian

Code:
<parameter name="isOnJS" class="java.lang.Boolean" isForPrompting="false">	<defaultValueExpression><![CDATA[boolean.valueOf($P{REPORT_URL_HANDLER_FACTORY} != null && $P{REPORT_URL_HANDLER_FACTORY}.createURLStreamHandler("repo") != null)]]></defaultValueExpression></parameter>
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...