My first post here will be a small note on how to configure Jasper Reports running on Jasper Report Server to contain hyperlinks to subreports. This may seem simple and intuitive but it really isn't. I've witnessed a lot of confusion and red-herring chasing on the net about this so I figured it's worth writing a rough set of instructions for how to do this. Here it is:
Sub Report
- In Jasper Reports Server, Create a separate Jasper Report for the subreport of choice.
- Create an Input Control that matches every parameter you expect to be passed to the subreport through the hyperlink.
Parent Report
- Right click on a text field of choice and select 'Hyperlink'.
- Set 'Hyperlink target' to "Self".
- Set 'Hyperlink type' to "ReportExecution".
- Click on 'Link parameters'.
- Create a report parameter called '_report'.
- Set its expression to a repository location using the "repo:" syntax. This part is strange.. it seems the url you provide here should be relative to two parent directories above the current report... e.g. for parent report at "/organizations/organization1/reports/parent", subreport at "/organizations/organization1/reports/subreport", set '_report' parameter to "repo:/reports/subreport" (with quotes).
- Set all the report parameters required. Ensure that the names of these parameters match the parameter names of the Input Controls defined for the sub report.
- Upload the report to Jasper Server
URL:
&reportUnit=%2Forganizations%2Forganization1%2Freports%2Fsubreport
Hyperlink:
&reportUnit=repo%3A%2Forganizations%2Forganization1%2Freports%2Fsubreport
.. it became clear that tweaking the "_report" parameter until the 'reportUnit' parameters were identical (save for the "repo:" prefix in the hyperlink) made for a working hyperlink.
For your reference, the error you get when clicking on a hyperlink that isn't correctly set is the following:
java.lang.NullPointerException at
com.jaspersoft.jasperserver.war.action.ResourceTypeMappingAction.doPreExecute(ResourceTypeMappingAction
.java:53) at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:186) at
org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) at
org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:79) at
org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188) at
org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145) at
org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) at
org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101) at
org.springframework.webflow.engine.State.enter(State.java:194) at
org.springframework.webflow.engine.Flow.start(Flow.java:535) at
org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:364) at
org.springframework.webflow.engine.impl.RequestControlContextImpl.start(RequestControlContextImpl.java:234)
at org.springframework.webflow.engine.SubflowState.doEnter(SubflowState.java:101) at
org.springframework.webflow.engine.State.enter(State.java:194) at
Also, it's worth noting that it isn't possible to pass parameters of any type other than those defined by the Input Controls in the subreport :(. Perhaps there's a way around this? I dunno...
Hope this helps someone!