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

how to dynamically adress a report unit as source for subreports


ronny.dathe

Recommended Posts

I have a report that needs to be delivered with a dynamic custom header.

To accomplish this, I used a subreport element that uses a header-type parameter to link to the correct header subreport.

This works fine in Jaspersoft Studio, but i cant get it to work on the server itself.

I already copied the folder structure thats on the server within my developemnt workspace so that path would be the same on both systems but no luck.

 

I guess I am doing something fundamentally wrong.

I have uploaded my header-subreports as individual report units within a headers folder.

Then, I uploaded the main Report which should use one of the headers depending on a parameter.

No matter how i change the subreport expression, the main report never works, while i can perfectly access the header on its own.

Here is some of the things i tried already, if at all they only worked in the dev studio:

standard path: "/reports/aaaaa/headers/"+$P{P_HEADER}+".jasper"

repo path: "repo:/reports/SecondaryDB/Headers/"+$P{P_HEADER}+".jasper"

tried omitting +".jasper" because i cannot see an actual jasper file, just a report unit.

tried to replace  +".jasper" with  +"/Main.jasper" or "/Main.jrxml"

tried using single or double backslash instead of forward slash

tried using the full external url to the header report

 

none of that seemed to work.

 

A thing I have not tried, including the headers right with the main report.

This is because I need to maintain the headers as a single, globally available instance, rather than having compiled copies of them in every single report.

 

Can someone plase give me an example how this can be achieved?

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Have you uploaded your header - subreports in JasperServer as jrxml files ?

Right-click in the headers folder on one of the jrxml files, and select the "Properties" menu-item

You need to make sure the path-info matches exactly to the "repo:..." syntax, including capitals. It might you have to omit any .jrxml, .jasper extension.

Link to comment
Share on other sites

Thanks filipc, got it working.

 

So apparently, my mistake was to upload the subreports as Report-Unit.

Now I use a plain folder with plain jrxmls, and no file extension in the subreport expression -  that works now.

 

But the other thing that confused me a lot, is that somehow my subreport expression gets altered while uploading.

My local developement file had it set to "repo:/reports/SecondaryDB/Headers/"+$P{P_HEADER}"

The upladed File had instead "repo:A_SPECIFIC_HEADER" and got rid of the path as well as the parameter, I guess JasperStudio did that implicitly.

I had to open my report unit and manually alter the main.jrxml on the server to set the subreport expressions back to what they should have been.

Only when I found that out, I finally got some results.

 

Follow-up Question:

Is there a way so I can use the same configuration for local dev as well as on the production server?

Currently I am using Jasper Studios upload function.

Manually altering subreport expressions whenever uploading changes is not exactly an elegant way to roll out reports.

Link to comment
Share on other sites

What version of JasperSoft Studio are you using. When you save the report in JasperSoft Studio and it automatically publishes the report to JasperServer as well, it overwrites expressions for subreports, images, ... You have to make sure you do not overwrite those while publishing.



 



How do you deploy from local DEV to PRD ? I would suggest you do it by using the export/import functionality in JasperServer ... It will automatically copy your DEV structure to the PRD server as well ... You only need to be aware if you also export and import the dependencies, on PRD your datasource connections will be overwritten.



 


Link to comment
Share on other sites

  • 2 weeks later...

Finally had a chance to test this, as I had to update some headers.

So I selected my updated header files in the local dev space and exported them to a zip archive.

However loading them on the server didnt work. It said "Invalid Export File".

Also tried using the Export to Jasper Server as File option. That however seemed only to do one file at a time although i had multiple selected.

So somehow thats not working either for reliable deployment.

 

Link to comment
Share on other sites

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...