More code sample for Java Fx ?

Stimulsoft Reports.JAVA discussion
Post Reply
scesari
Posts: 7
Joined: Mon Mar 24, 2014 1:21 pm

More code sample for Java Fx ?

Post by scesari »

Hi stimulsoft team,

I try to use Java Fx product and I have a lot of problems to run webdesigner correctly. In fact, I saw your sample with your xsd schema but it doesn't show how to define relations between tables (for example between product and category).
But I see in your live demo the relation exists between this two tables. I want to know if it's possible to download your sample source code to configure correctly the webdesigner. Or if it's possible to have more explainations.
In a perfect world, I want to construct report dictionnary datasource with my bean objects and not with an xsd schema. So I need to understand how can I create tables, fields and relation (one to many and many to one) and how can I construct my xml datas to preview or print a report.
Thanks for your answer.

Best regards

--
Sylvain
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: More code sample for Java Fx ?

Post by Vadim »

Hello.

Here is the sample of creating report with relation.
scesari wrote:Hi stimulsoft team,

I try to use Java Fx product and I have a lot of problems to run webdesigner correctly. In fact, I saw your sample with your xsd schema but it doesn't show how to define relations between tables (for example between product and category).
But I see in your live demo the relation exists between this two tables. I want to know if it's possible to download your sample source code to configure correctly the webdesigner. Or if it's possible to have more explainations.
In a perfect world, I want to construct report dictionnary datasource with my bean objects and not with an xsd schema. So I need to understand how can I create tables, fields and relation (one to many and many to one) and how can I construct my xml datas to preview or print a report.
Thanks for your answer.

Best regards

--
Sylvain
Attachments
CreateRelationsReport.txt
(9.05 KiB) Downloaded 294 times
scesari
Posts: 7
Joined: Mon Mar 24, 2014 1:21 pm

Re: More code sample for Java Fx ?

Post by scesari »

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.
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: More code sample for Java Fx ?

Post by Vadim »

Hello scesari.

Here is example of Object relation (it implementation will present in next prerelease build).

According to your error - you must remove your (custom) databases from report before save (serialize it)

Code: Select all

public void onSaveReportTemplate(StiReport report, String reportName, HttpServletRequest request){
...
//for example report.getDictionary().getDatabases().clear();
}
scesari wrote: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.
Attachments
CreateRelationsReport.txt
(9.26 KiB) Downloaded 263 times
scesari
Posts: 7
Joined: Mon Mar 24, 2014 1:21 pm

Re: More code sample for Java Fx ?

Post by scesari »

Thanks for this information.
About my error, the exception is not throw when I try to save my report but when I try to preview my report (click on preview tab on HTML5 designer). And if I remove databases to my report I haven't got datas to display and my report is empty on preview.
Why isn't it possible to serialize my custom database like your StiXmlDatabase ?
How can I populate my report preview with datas if I should remove databases on report ?
Sorry for all this questions but I'm beginner with your product and I want to understand it.
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: More code sample for Java Fx ?

Post by Vadim »

Hello scesari.

We fixed such behaviour, you can use object beans as database (since next prerelease). Please don't make database beans as nested classes.
scesari wrote:Thanks for this information.
About my error, the exception is not throw when I try to save my report but when I try to preview my report (click on preview tab on HTML5 designer). And if I remove databases to my report I haven't got datas to display and my report is empty on preview.
Why isn't it possible to serialize my custom database like your StiXmlDatabase ?
How can I populate my report preview with datas if I should remove databases on report ?
Sorry for all this questions but I'm beginner with your product and I want to understand it.
Post Reply