helmut Posted April 9, 2008 Share Posted April 9, 2008 Hi folks,I need to draw a rectangle (with radius) around a subreport, which I have managed by putting the rectangle and the subreport into an element group of the main report and setting the correct strecht type. This works fine. My problem though is that the subreport can be empty. In this case the rectangle is still drawn, but it should also not be printed!!! :( Does anybody have a solution for this problem? Link to comment Share on other sites More sharing options...
Telos Posted April 10, 2008 Share Posted April 10, 2008 A slightly ugly solution that comes to mind is to create an intermediate subreport that has only your rectangle and the original subreport. It should have the same datasource as the original subreport, and therefore if the datasource is empty the intermediate subreport (and the therefore the rectangle) won't be shown. Alternatively, if you have a way of determining the size of your datasource you could use that information in the printWhenExpression of the rectangle. Link to comment Share on other sites More sharing options...
helmut Posted April 10, 2008 Author Share Posted April 10, 2008 Hello Telos,Thank you for your quick reply! I have implemented your the solution using an 'intermediate' subreport. This works fine. (and at the same time solves some other issues) Just out of interest: How could I determined the size of my data source in a 'printWhenExpression'. Do I have to use a scriptlet or can I solve this with a 'conventional' expression? Thank you again for your support!RegardsHelmut Link to comment Share on other sites More sharing options...
C-Box Posted April 11, 2008 Share Posted April 11, 2008 Do you use an implementation of JRDataSource? If so, you could extend it to your own and just make a method like this: Code:public Integer getRecordCount(){ return this.recordsObjectArrayListMapOrWhatEver.size();} in your PrintWhenExpression you could easily use: Code:[code]new Boolean($P{MySubReportDataSource}.getRecordCount().intValue() >0) So I did with my FilterableDTODatasource. WOrks fine!! Just give it a try. hthC-Box Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now