Home
Analytics
Where does WebViewerExample data comes from?
Yufan
Hi,<br />
<br />
Currently Birt API is used in our applications, my job is development with its API.<br />
<br />
I have a problem with the example application "WebViewerExample" which is in the birt runtime folder.<br />
<br />
There is a template file tset1.rptdesign, which contains some charts and format. I tried to find out how does this example call its API through those js and jsp, but I failed. Can someone show me how does this example application "WebViewerExample(birt.war)" works?<br />
<br />
The template file is also used in my application, deployed on my server and bugs are resolved. Now there is a little problem that it requires to call task.setparameters() for config the template parameter "Cust".<br />
<br />
In the test1.rptdesign it is:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><scalar-parameter name="Cust" id="59">
<property name="valueType">static</property>
<property name="dataType">decimal</property>
<property name="paramType">simple</property>
<text-property name="promptText">CustomerNumber in list less than</text-property>
<...>
</pre>
<br />
This is the part confusing that I really can not find which js in the js application "set" this parameter. I only found a task.setParameterGroup() within the js, is it?<br />
<br />
The last question, on the homepage there are few tutorials about the calling API. I believed that I did not find the right place, can someone show some links regarding to calling those API and generates reports?<br />
<br />
Heartful Thanks,<br />
<br />
Yufan
Find more posts tagged with
Comments
Yufan
I think that I found some after study the source codes and templates.<br />
<br />
In the rptdesign file, user can define the datasource for a report. For example, the WebViewerExample has a test1.design, and it defines the data source like this:<pre class='_prettyXprint _lang-auto _linenums:0'><data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source" id="26">
<property name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver</property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
</oda-data-source>
</data-sources></pre>
<br />
There is a jdbc provides demo data for this report, it used queries like <pre class='_prettyXprint _lang-auto _linenums:0'><property name="queryText">select * from CLASSICMODELS.CUSTOMERS</property></pre> in the same report templates to define the query.<br />
<br />
But how to use an arraylist setting the dataset for a report template?
mwilliams
So, your data is in an arrayList and you want to use it in a report? If so, you'd need to create a report design with a scripted dataset. You'd bring in your data in the open method of the scripted dataset, then step through and assign it to columns in the fetch method. Deploying the report to the web viewer is as simple as copying the report into the webviewer folder.
The example report design uses the sample database which is part of the runtime. When you deploy your report, you'd just need to remember to deploy your class file or wherever you get your ArrayList of data from, so that the report can access it.
Let me know if I'm misunderstanding your question.
Yufan
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="116467" data-time="1367638958" data-date="03 May 2013 - 08:42 PM"><p>
So, your data is in an arrayList and you want to use it in a report? If so, you'd need to create a report design with a scripted dataset. You'd bring in your data in the open method of the scripted dataset, then step through and assign it to columns in the fetch method. Deploying the report to the web viewer is as simple as copying the report into the webviewer folder.<br />
<br />
The example report design uses the sample database which is part of the runtime. When you deploy your report, you'd just need to remember to deploy your class file or wherever you get your ArrayList of data from, so that the report can access it.<br />
<br />
Let me know if I'm misunderstanding your question.<br /></p></blockquote>
<br />
Hi Michael, <br />
<br />
Thanks for your reply! Your answer is exactly what I am looking for.<br />
<br />
Actually I found the runtime database URL, ports, username and password in the xml (.rptdesign) file.<br />
<br />
But I was confusing how to loop arraylist as datasource to generate the report.<br />
<br />
So we need to parse the raw data arraylist into the jsp. Then inside the jsp, we can using a java script function to call Birt API task.setDefinedParameters() and task.run() and generates the report.<br />
<br />
Is my understanding correct?
mwilliams
No, you should be able to connect to your java file that has your arrayList in the open method of the scripted dataSet you create in your report. From there, you can step through your arrayList, creating the rows for your result set. The data connection, layout, etc should all be able to be done within your report design, then you'd just deploy this design to the viewer and call it by URL. Hope this makes more sense.
Yufan
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="116566" data-time="1367964315" data-date="07 May 2013 - 03:05 PM"><p>
No, you should be able to connect to your java file that has your arrayList in the open method of the scripted dataSet you create in your report. From there, you can step through your arrayList, creating the rows for your result set. The data connection, layout, etc should all be able to be done within your report design, then you'd just deploy this design to the viewer and call it by URL. Hope this makes more sense.<br /></p></blockquote>
<br />
Hi, <br />
<br />
Thanks a lot for your replies. Now I figured it out. I have done exactly same as your guidence in the 'Open' and 'Fetch' method by using java scripts.<br />
<br />
Now I can succesfully running my report on Jboss as html page in the browser. :wub: <br />
<br />
Thank you.
mwilliams
Awesome! I'm always glad to help! Let us know whenever you have questions!