Using Business Objects in java

Stimulsoft Reports.JAVA discussion
Post Reply
numiareced
Posts: 1
Joined: Fri May 05, 2023 3:05 pm

Using Business Objects in java

Post by numiareced »

Hi there,
I'm using the latest set of jar dependencies (2023.2.2) to generate Report and I want to dynamically provide Business Objects values inside the code during report generation.

Is there any sample that I can use from java? All I can find is .net related and a lot of methods showed there are either empty or not available at all.

What I want to achieve is to add some Business Object to template (for example something simple for instance, just an object with one string field "name") and then during report generation I want to set the actual value for that business object from code, without using db (for instance - I want to propagate username from token, not from db).

What I did so far, is that I've created business objects during template creation like this:

var businessObjects = report.dictionary.getBusinessObjects();
StiBusinessObject propertyName = new StiBusinessObject("cat1", "PropertyNameBO", "PropertyNameBO", "PropertyNameBO");
propertyName.getColumns().add(new StiDataColumn("propertyName", "propertyName", StiSystemType.getSystemType("System.String")));
businessObjects.add(propertyName);


After that I've added a field in my template that access the column ( {PropertyNameBO.propertyName} )And now at the time when report should be generated, I want to somehow provide the values to this object. I've tried something like this:

var businessObjects = globalReport.getDictionary().getBusinessObjects();
var object = businessObjects.getItem("PropertyNameBO");

var objValue = new PropertyNameBO();
objValue.setPropertyName("MY NAME");
object.setBusinessObjectValue(objValue);

but nothing changed and the field doesn't appear during report generation.
I've then found that StiBusinessObjectData exists and tried to set it instead of BusinessObjectValue during report generation:

var data = new StiBusinessObjectData("cat1", "PropertyNameBO", objValue);
globalReport.getBusinessObjectsStore().add(data);

But nothing happened again.
I've have a feeling that I'm doing something completely wrong, but I've searched through all internet and cannot find any answer, so I would really appreciate any help.
Vadim
Posts: 362
Joined: Tue Apr 23, 2013 11:23 am

Re: Using Business Objects in java

Post by Vadim »

Hello.

Java version does not support BusinessObjects, you can do your own database like in sample https://www.stimulsoft.com/en/samples/r ... at-runtime
Post Reply