0
Good afternoon,
I am creating a report in Jasper that contains a sub-report (with Jaspersoft Studio). For this to be loaded, I have to indicate the directory of the sub-report, which is in the same folder as the parent report. I am currently using the following method in the parent report:
<subreport>
<reportElement x="1" y="65" width="250" height="25" uuid="330b01bb-6d94-4644-b718-0fe59f69ce93"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["C:\\Users\\john\\Desktop\\reports\\subreport_test.jasper"]]></subreportExpression>
</subreport>
This way, it can load. It works! However, I wanted it to be dynamic: That is, that the subreportExpression detects directly where it is, and so would not have to enter the 'hard-coded' location, as in the code above.
For the research I did on the Internet, can be used the $P{SUBREPORT_DIR}, but in my case gives me null. I also tried to use the following expression:
<subreportExpression><![CDATA["subreport_test.jasper"]]></subreportExpression>
But to no avail. He can’t detect where he is.
Anyone have any suggestions? Thank you!
Hello Denis, thank you for your reply. However, my goal would be not to put the directory 'hard coded'. I wish, somehow, there was a way to have a variable that would detect the path where the report is, and then yes, from there, do the " <![CDATA[$P{SUBREPORT_DIR} + "Embarque_relacao_subreport1.Jasper"]]>". This is because it is a client project. On my localhost, the path to the reports folder may be X, but on the client, the path is different, so I wanted to find a dynamic way to detect where the reports are.
– cortereal
Voce can do this my dear when Voce inform a Map parameters for example in your case if I wanted to change the default value of the parameter $P{SUBREPORT_DIR} would do as follows: parameters.put("SUBREPORT_DIR","C: Users john Desktop Reports");', edit my answer above to be clearer
– Denis Benjamim
Remembering that in my case I distribute my application for several machines using the relative patch technique I told you above I never needed to change in anyone’s computer, because the path is not the absolute but the relative
– Denis Benjamim