hussainian Posted June 28, 2010 Share Posted June 28, 2010 Hi!Can we prevent a report to be generated from Scriptlet's beforeReportInit or afterReportInit methods?Thanks.AsadUllah. Link to comment Share on other sites More sharing options...
hussainian Posted June 28, 2010 Author Share Posted June 28, 2010 One way I'm doing it is using a function in PrintWhenExpression of all bands. This function in the scriptlet performs the logical part and returns TRUE or FALSE. So if the function returns TRUE, the bands are printed and if FALSE the report seems to be blank white page. Though this solves the problem, but it seems illogical to go through all the report generation process even for the case when the report is not meant to be displayed. So is their any way we can stop the generation process in the start?Thanks.AsadUllah. Link to comment Share on other sites More sharing options...
lucianc Posted July 2, 2010 Share Posted July 2, 2010 Wouldn't throwing an exception do it?Regards,Lucian Link to comment Share on other sites More sharing options...
hussainian Posted July 3, 2010 Author Share Posted July 3, 2010 Well! The work done. I'm using JasperServer to view reports. Now what happens that a very long and odd Stack Trace is printed on the screen. Is there any way to remove this track and print own message?Thanks Lucian.Asad.Post Edited by hussainian at 03/07/2010 11:30 AM Link to comment Share on other sites More sharing options...
lucianc Posted July 5, 2010 Share Posted July 5, 2010 hussainianWrote: Is there any way to remove this track and print own message? I think you'd have to customize JasperServer for that.Or you could do something else: use your current report as a subreport, and perform the check in the master report. If the check fails, print a text field with the message. If the check succeeds, include the subreport (via its print when expression).Or, a slightly better version of your solution: use the report's filter expression to skip all records from the data source, and print a message in the "no data" band. The report would still fetch all records from the data source, but it wouldn't perform any layout work.Regards,Lucian 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