Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Assiging data set to table through Dynamic Servlet
Rapporter
Hi Everyone,
i was going through the Dynamic Servelet Example and was able to run it successfully. Now i want to design my report through through drag and drop thing. I designed my report but i am not able to add data set for my table as i am not desiging it through Servlet. i am getting this Exception
org.eclipse.birt.report.model.api.command.ContentException: The ODA Data Source(
"Data Source") is not allowed in the slot (dataSets) of report.
at org.eclipse.birt.report.model.util.ContentExceptionFactory.createCont
entException(ContentExceptionFactory.java:43)
at org.eclipse.birt.report.model.command.AbstractContentCommand.checkBef
oreAdd(AbstractContentCommand.java:176)
at org.eclipse.birt.report.model.command.ContentCommand.checkBeforeAdd(C
ontentCommand.java:160)
at org.eclipse.birt.report.model.command.AbstractContentCommand.add(Abst
ractContentCommand.java:137)
at org.eclipse.birt.report.model.command.AbstractContentCommand.add(Abst
ractContentCommand.java:246)
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:130)
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:84)
Any Help will be appreciated.Thanks.It is bit Urgent.
Find more posts tagged with
Comments
JasonW
Can you post your code?
Jason
Rapporter
ElementFactory designFactory = designHandle.getElementFactory();
OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource("Data Source", "org.eclipse.birt.report.data.oda.jdbc");
dsHandle.setProperty("odaDriverClass","com.mysql.jdbc.Driver");
dsHandle.setProperty("odaURL", "jdbc:mysql://localhost:3306/testdb");
dsHandle.setProperty("odaUser", "root");
dsHandle.setProperty("odaPassword", "");
designHandle.getDataSources().add(dsHandle);
OdaDataSetHandle odadsHandle = designFactory.newOdaDataSet("ds","org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet");
odadsHandle.setDataSource("Data Source");
String strQuery = "";
strQuery=(new StringBuilder(String.valueOf(strQuery))).append(" SELECT * FROM USER ").toString();
odadsHandle.setQueryText(strQuery);
designHandle.getDataSets().add(dsHandle);
Rapporter
Please Ignore my previos post. I had made a small mistake there. That is working fine now.
The problem which I am facing now it how to add detail row to my existing table. Element Factory only has create new table option. I am no sure how to access the table already in rptdesign file and add detail row to it. Any help will be appreciated.
alex520
designHandle.findElement("your_table_name"); //will return your table<br />
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );<br />
for( int i=0; i < cols.size(); i++){<br />
CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );<br />
DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );<br />
data.setResultSetColumn( (String)cols.get(i));<br />
cell.getContent( ).add( data );<br />
}<br />
<br />
designHandle.getBody( ).add( table );<br />
<br />
you may also want to look at <br />
<a class='bbc_url' href='
http://wiki.eclipse.org/Java_-_Build_Dynamic_Table_(BIRT'>Java
- Build Dynamic Table (BIRT - Eclipsepedia</a>)