Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
how to run a sql-statement in an handler/java resource
shazia
I run birt reports in my web application.<br />
<br />
After the user has specified the parameters in a report, I run a dataset/sql-statement to get some result back. This part is ok.<br />
<br />
<strong class='bbc'>But I want to achieve this:</strong><br />
i want to run another sql-statement to some other database (before the report sql-statement stated over) to validate that the user has the right to run this report with the parameters given.<br />
<br />
Can this be achieved by using a handler ?<br />
<br />
Please guide me how I can access a mysql-database and run sql-statement from an handler, java resource or javascript within a birt report ?
Find more posts tagged with
Comments
johnw
Yes. There is a validate event handler on parameters you can use. It is also possible to populate parameters with values from a dataset so that the user can only see parameters that they are entitled to. You can override the event handlers on the data set itself to verify that the user has rights to run that query, and throw an exception if they do not.
The easiest route is going to be to only display parameters from a data set that they have access to. Take a look in the Resources/Documentation section of the site. There are plenty of tutorials on how to do data driven parameters in the report developers documentation.
shazia
Hi johnw,<br />
<br />
thanks for your apply.<br />
<br />
the reason i want to validate the parameter after given by the user, is cause of if the user gives the parameters through the URL (as GET-parameters) when running the report.<br />
<br />
i tried to look through the Resources/Documentation section, but i could only see Actuate 11SP3 Documentation. I am using birt report viewer as opensource.<br />
<br />
Could you please guide me how to "validate event handler on parameters"?<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="110297" data-time="1349802746" data-date="09 October 2012 - 10:12 AM"><p>
Yes. There is a validate event handler on parameters you can use. It is also possible to populate parameters with values from a dataset so that the user can only see parameters that they are entitled to. You can override the event handlers on the data set itself to verify that the user has rights to run that query, and throw an exception if they do not.<br />
<br />
The easiest route is going to be to only display parameters from a data set that they have access to. Take a look in the Resources/Documentation section of the site. There are plenty of tutorials on how to do data driven parameters in the report developers documentation.<br /></p></blockquote>
johnw
http://help.eclipse.org/juno/index.jsp
shazia
Hi again,<br />
<br />
thanks for your message.<br />
<br />
i have used the whole day today trying to find a way to do this. <br />
<br />
I now see that the easiest way to do achieve my goal is to script "validate"-event on a parameter, or make a custom event handler on the parameter.<br />
<br />
but sadly i dont know how to. trying to figure out.<br />
<br />
I have tried to find a custom validation example, but cant seem to find any example. seems wierd that no-one has not done custom validation yet ? I just want to show a custom message-error thrown from the validate-event.. if i for example write false in the validate-event script for a parameter. it gives me this error:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>org.eclipse.birt.report.service.api.ReportServiceException: The validation for parameter "date1" fails. (Element ID:7)
Show Exception Stack Trace
Hide Exception Stack Trace
Stack Trace:
org.eclipse.birt.report.service.api.ReportServiceException: The validation for parameter "date1" fails. (Element ID:7)
at org.eclipse.birt.report.service.ReportEngineService.throwDummyException(ReportEngineService.java:1115)
at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:943)
at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
at org.eclipse.birt.report.service.actionhandler.BirtGetPageAllActionHandler.__execute(BirtGetPageAllActionHandler.java:131)
at org.eclipse.birt.
</pre>
<br />
<br />
appreciate all help. thanks.<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="110336" data-time="1349816808" data-date="09 October 2012 - 02:06 PM"><p>
<a class='bbc_url' href='
http://help.eclipse.org/juno/index.jsp'>http://help.eclipse.org/juno/index.jsp</a><br
/></p></blockquote>
shazia
Hi,<br />
<br />
figured out that its no easy way to show custom-messages on validate-event for a parameter. And returning false or true is the way to go.<br />
<br />
Now im trying to run a dataset from the parameter validate-event. I know how to get a dataset with javascript. But how to run and retrieve the resultset ?<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();
var dset = reportContext.getDesignHandle().findDataSet("DataSet1");
</pre>
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'shazia'" data-cid="110359" data-time="1349876882" data-date="10 October 2012 - 06:48 AM"><p>
Hi again,<br />
<br />
thanks for your message.<br />
<br />
i have used the whole day today trying to find a way to do this. <br />
<br />
I now see that the easiest way to do achieve my goal is to script "validate"-event on a parameter, or make a custom event handler on the parameter.<br />
<br />
but sadly i dont know how to. trying to figure out.<br />
<br />
I have tried to find a custom validation example, but cant seem to find any example. seems wierd that no-one has not done custom validation yet ? I just want to show a custom message-error thrown from the validate-event.. if i for example write false in the validate-event script for a parameter. it gives me this error:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>org.eclipse.birt.report.service.api.ReportServiceException: The validation for parameter "date1" fails. (Element ID:7)
Show Exception Stack Trace
Hide Exception Stack Trace
Stack Trace:
org.eclipse.birt.report.service.api.ReportServiceException: The validation for parameter "date1" fails. (Element ID:7)
at org.eclipse.birt.report.service.ReportEngineService.throwDummyException(ReportEngineService.java:1115)
at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:943)
at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
at org.eclipse.birt.report.service.actionhandler.BirtGetPageAllActionHandler.__execute(BirtGetPageAllActionHandler.java:131)
at org.eclipse.birt.
</pre>
<br />
<br />
appreciate all help. thanks.<br /></p></blockquote>