Jump to content
  • Running A Report Local And Remote


    mrcaffeine

    Purpose

    When you are developing reports running on JasperReports Server containing references to other resources such as images or subreports you will need to set the element expression to a valid repository URI. These URI's can't be solved by iReport Designer by default. This guide shows you how to setup reports being able to run in the JasperReports Server repository (remote) and in iReport Designer (local).

    The sample was developed on JasperReports Server Pro version 3.5.1 and iReport Designer Pro 3.5.0. 

    There is one main report containg a query and a list of data, in the title band there is an image reference, in the summary is a subreport referenced.The report is configured to use Java as language.

    The Implementation

    I use a report parameter as switch for the URIs.

    The Parameter settings are:

    • Name: runRemote
    • Parameter Class: java.lang.Boolean
    • Use as prompt: yes
    • Default Value Expression: new Boolean(true)
      subreport image
    local expression "C:reportsrunningLocalAndRemoteSub.jasper" "C:reportsimageslittleLady.jpg"
    remote expression "repo:runningLocalAndRemoteSub.jrxml" "repo:littleLady.jpg"

    I changed the Subreport Expression: 

    $P{runRemote}.booleanValue() ? "repo:runningLocalAndRemoteSub.jrxml" : "C:reportsrunningLocalAndRemoteSub.jasper"

    I also changed the image Expression: 

    $P{runRemote}.booleanValue() ? "repo:littleLady.jpg" : "C:reportsimageslittleLady.jpg"

    I used the absolute path reference for running the reports locally because the report gets copied into a temporary folder once opened from the JasperServer repository using the JasperReports Server plugin. Resources which are referenced relative wouldn't be found.

    When you run the report in iReport Designer you get prompted for the parameter runRemote. Enter false as value. Now the report expressions for local execution get used. Update the report unit in JasperReports Server by re-deploying the JRXML file. You don't need to define an input control, the default setting for the parameter will be used.

    The Report

    Main_report.png.14461f2fb940d0d4d2076fcf74081a9e.png

    report design

     

    Main_report_output.png.18ad2cae7818bca4f876aa80e2115c8b.png

    report output - both from JasperReports Server and from iReport Designer without changing the sources.

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...