On Sep 3, 2004, at 11:06, Jürgen Saar wrote:
> I've got one problem: It seems to me, that JasperReports
> only processes one flat resultset, but has no interface
> for resultsets of object relational objects.
>
> If you have an Invoice, I think you have an order
> and an order has positions, if take a simple structure.
>
> How did you solve the accesss to the relation data
> in JRDataSource?
My relation looks like order<-->>order_product. A single order has one
or more order_products. My custom JRDataSource takes a single order in
its constructor. The next() method of JRDataSource increments an index
that is used to pick the current order_product. The
getFieldValue(JRField) are the interesting part. I guess my solution is
not the most elegant, but it is working. I have to explain it by an
example:
public Object getFieldValue(JRField jrField) throws JRException {
String name = jrField.getName();
if ("distributorName".equals(name)) {
return getOrder().getDistributor().getName();
} else if ("customerName".equals(name)) {
return getOrder().getCustomer().getName();
} else if ("productId".equals(name)) {
return getCurrentOrderProduct().getProduct().getProductId();
} else if ("price".equals(name)) {
return getOrder().getTotalDiscountedPrice();
} else if ("productPrice".equals(name)) {
return getCurrentOrderProduct().getDiscountedPrice();
} else if ("orderId".equals(name)) {
return getOrder().getOrderId();
} else if ("referenceNumber".equals(name)) {
return getOrder().getReferenceNumber();
}
log.error("did not match any of the tests: " + name);
return null;
}
* Some of the properties on "order" could be passed as parameters
instead of in the model.
* It should be possible to use cayenne path instead of hardcoded
strings, but I didnt bother to figure out.
Sorry for this late answer.
- Tore.
>
> Tore Halset <halse..vv.ntnu.no> schrieb am 02.09.04 12:58:39:
>>
>> On Sep 2, 2004, at 10:16, Jürgen Saar wrote:
>>
>>> is there any experience using JasperReports with cayenne ?
>>
>> I am using JasperReport with cayenne to display invoices in different
>> ways. I created a custom JRDataSource that takes a single Invoice
>> cayenne object. I used iReport[1] to create the template.
>>
>> [1] http://ireport.sourceforge.net/
>>
>> - Tore.
>
>
> _______________________________________________________
> WEB.DE Video-Mail - Sagen Sie mehr mit bewegten Bildern
> Informationen unter: http://freemail.web.de/?mc=021199
This archive was generated by hypermail 2.0.0 : Tue Sep 07 2004 - 12:39:32 EDT