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)
How to access existing POJOs in a birt report
elliottg
New user question
We have discovered how we can pass in existing Java objects to a report using
HashMap hm = config.getAppContext();
hm.put("patientContext", patientInstance);
in the code that executes the report.
In the report design we can create a data field with a data binding expression set to patientContext.name and the data from the object is correctly inserted at run time.
We have got this working for simple single value data fields.
But how do we bind a List or Table element to an existing ArrayList object?
For instance if we use:
ArrayList<String> testArray = new ArrayList<String>();
testArray.add("lifestyle data 1");
testArray.add("lifestyle data 2");
HashMap hm = config.getAppContext();
hm.put("listContext", testArray);
How do we bind to listContext in the report. Do we need a Dataset that references listContext with open and fetch handlers?
I have tried to do this:
<data-sets>
<script-data-set name="listDataset" id="768">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">text</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">text</property>
<property name="displayName">text</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">text</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[count = 0;
list = listContext;]]></method>
<method name="fetch"><![CDATA[if(count < list.size() - 1)
{
count++;
row["text"] = list.get(count);
return true;
}
return false;
]]></method>
</script-data-set>
</data-sets>
But this doesn't seem to work. Is this the right approach?
Find more posts tagged with
Comments
Davolio
This link might not be what you're looking for but somewhere in this below post Mike links to a devshare about working with Java objects that may be useful.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/forum/designing-birt-reports/13494-beginer-looking-examples-java.html'>http://www.birt-exchange.org/forum/designing-birt-reports/13494-beginer-looking-examples-java.html</a><br
/>
<br />
Hope that helps,<br />
<br />
Dave