Jump to content

How to create a header file to use on reports and be able to update the header file that will cascade down and update the reports?


jndh90

Recommended Posts

I would like to create a header file that can be used on several reports in Jasper that are loaded on the JasperServer.  In turn I would like to update this header file in one location which inturn will update all the reports in Jasper without having to manually go into each report to update it.

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Here are things I have tried: create a header file and load it to the repository as a jrxml file.  On my report reference the jrxml file as a subreport in the subreport expression.

Create a header file and load it to the repository as a report.  On my report reference the report as a subreport in the subreport expression.  I get net.sf.jasperreports.engine.JRException: Error opening input stream from URL in both cases.

Must the header file to referenced within the report and loaded to the resource folder or can the header file be referenced outside the report but still in the same location on the repository as where the report resides?  Most information I have found says it must be loaded as a resouce under the report.  I would like to use this header file on several reports and be able to update the header file once and the reports using this file will also get updated.  If I have to load the header file as a resource under each report then this defeats the purpose of updating the file in one location.

Link to comment
Share on other sites

Use the full path to refer to header report. It works well, I have tested.

example code

In main report, put a subreport refer to Header report.


        
            
                
                new net.sf.jasperreports.engine.JREmptyDataSource()
                "repo:/public/header/header.jrxml"
            
        
    

Hope this help.

Link to comment
Share on other sites

Thanks for the response. Not quite following however. Where do I put the full path. I have the ltr_hdr.jrxml loaded to the repository. I've added a subreport to my letter and in the subreport expression put "repo:ltr_hdr.jrxml". I upload the letter to the repository but it won't load the subreport in to the resources folder. Should it load it there? I've tried running the report on the server but I get the same error I've been getting: Error opening input stream for URL: repo:ltr_hdr.jrxml.
Link to comment
Share on other sites

  • 4 weeks later...

For any that are wanting a solution, this is what I ended up doing.  I created the header file first and saved it on my local machine.  I also loaded the file as a jrxml file to the repository.  On my report I add the header file as a subreport.  Load the report to the repository and it creates a resource with the subreport.  Then I log into Jasper server, search for the report in the repository, right click and edit.  I go to control & resources, click on the name of the subreport, this brings me to another page where I can select a file from the repository.  I search in the repository for the .jrxml file that I had loaded, save and submit.  This replaces the subreport in the resources under the report to the file that is stored directly on the repository and creates a linked file.  If I go back into iReports and look at the subreport under the reports resource folder there is an icon with a chain link next to the name of the subreport.  Now when I make a change to the file, it will update in my report.

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