Hi Vadim,
Thanks for your very interesting answer. It helps me a lot. I have a last question about relations :
In your sample the relation is create with cId column of type System.Int32. Is it possible to define a relation on an Object ?
If I have my Parent object which contains a property of type Children. How can I define this relation ?
For information, we use the HTML5 report for JAVA, so I code a JSP page. When I try your sample I have an error on preview :
Caused by: java.lang.ClassCastException: com.asis.kis.poc.restx.Stimulsoft.UniversDataBase cannot be cast to com.stimulsoft.base.serializing.interfaceobject.IStiSerializableRef
at com.stimulsoft.base.serializing.StiSerializerReport.serializeParentInCollection(StiSerializerReport.java:205)
at com.stimulsoft.base.serializing.StiSerializerReport.serializeObjectCollection(StiSerializerReport.java:198)
at com.stimulsoft.base.serializing.StiSerializerReport.serializeCollection(StiSerializerReport.java:168)
at com.stimulsoft.base.serializing.StiSerializerReport.processOnDependingType(StiSerializerReport.java:81)
at com.stimulsoft.base.serializing.StiSerializerReport.serializProperty(StiSerializerReport.java:70)
at com.stimulsoft.base.serializing.StiSerializerReport.serialize(StiSerializerReport.java:58)
at com.stimulsoft.base.serializing.StiSerializerControler.serializeBranch(StiSerializerControler.java:196)
at com.stimulsoft.base.serializing.StiSerializerReport.serializeParent(StiSerializerReport.java:151)
I have a class which extends StiDatabase call UniversDataBase and I don't understand why the system throw this exception.
Here the definition of my class :
Code: Select all
public class UniversDataBase extends StiDatabase {
public UniversDataBase(){
this("");
}
public UniversDataBase(String databaseName) {
super(databaseName, databaseName);// Database name
}
@Override
public void connect(StiDataStoreSource stiDataStoreSource) throws StiException {
System.out.println("passed in connect method");
}
@Override
public void disconnect() {
}
}
And here the code of the onNewReportTemplate include in my JSP page
Code: Select all
public void onNewReportTemplate(StiReport report, HttpServletRequest request){
report.getDictionary().getDatabases().add(new UniversDataBase("Support"));
report.getDictionary().getDatabases().add(new UniversDataBase("Box"));
StiDataTableSource supportSource = getTableSourceSupport();
supportSource.setDictionary(report.getDictionary());
report.getDictionary().getDataSources().add(supportSource);
StiDataTableSource boxSource = getTableSourceBox();
boxSource.setDictionary(report.getDictionary());
report.getDictionary().getDataSources().add(boxSource);
ArrayList<String> parentColumn = new ArrayList<String>();
parentColumn.add("Id");
ArrayList<String> childColumn = new ArrayList<String>();
childColumn.add("support");
StiDataRelation relation = new StiDataRelation("Support", supportSource, boxSource, parentColumn, childColumn);
boxSource.getDictionary().getRelations().add(relation);
}
private StiDataTableSource getTableSourceSupport() {
StiDataTableSource tableSource2 = new StiDataTableSource("datas.Support", "Support");
tableSource2.setColumns(new StiDataColumnsCollection());
tableSource2.getColumns().add(
new StiDataColumn("Id", "Id", StiSystemType.getSystemType("System.Int32"))
);
tableSource2.getColumns().add(
new StiDataColumn("status", "status", StiSystemType.getSystemType("System.Int32"))
);
tableSource2.getColumns().add(
new StiDataColumn("mDate", "mDate", StiSystemType.getSystemType("System.String"))
);
return tableSource2;
}
private StiDataTableSource getTableSourceBox(){
StiDataTableSource tableSource1 = new StiDataTableSource("datas.Box", "Box");
tableSource1.setColumns(new StiDataColumnsCollection());
tableSource1.getColumns().add(
new StiDataColumn("Id", "Id", StiSystemType.getSystemType("System.Int32"))
);
tableSource1.getColumns().add(
new StiDataColumn("status", "status", StiSystemType.getSystemType("System.Int32"))
);
tableSource1.getColumns().add(
new StiDataColumn("mDate", "mDate", StiSystemType.getSystemType("System.String"))
);
tableSource1.getColumns().add(
new StiDataColumn("IdSup", "IdSup", StiSystemType.getSystemType("System.Int32"))
);
return tableSource1;
}
With this when I load an empty report, the exception is throw when I try to see the preview of the report.
Thanks for your answer.