如何在动态碧玉报表中设置布尔属性

时间:2019-12-29 15:45:53

标签: java jasper-reports dynamic-jasper

我正在使用Dynamic Jasper Report API在JavaFX应用程序中生成报告。但是我需要帮助来在jasper报告中设置布尔类型属性。

相同的代码段如下所述:-

    @FXML
    public void showBookDetailsReport(ActionEvent event) {

        String searchByCriteria=cmbSearchBy.getValue();
        String searchByValue=txtSearchField.getText();

        List<BookDetailsModel> lstBookDetailsModel=null;
        if(searchByCriteria.equals("Accession No")) {
            lstBookDetailsModel=getDataAccordingToAccessionNo(searchByValue);
        }else if(searchByCriteria.equals("Title")) {
            lstBookDetailsModel=getDataAccordingToTitle(searchByValue);
        }else if(searchByCriteria.equals("ISBN")) {
            lstBookDetailsModel=getDataAccordingToISBN(searchByValue);
        }else if(searchByCriteria.equals("Category")) {
            lstBookDetailsModel=getDataAccordingToCategory(searchByValue);
        }else if(searchByCriteria.equals("Subject")) {
            lstBookDetailsModel=getDataAccordingToSubject(searchByValue);
        }else if(searchByCriteria.equals("Author")) {
            lstBookDetailsModel=getDataAccordingToAuthor(searchByValue);
        }else if(searchByCriteria.equals("Book Lost")) {
            lstBookDetailsModel=getDataAccordingToIsBookLost();
        }


        JasperReportBuilder report = DynamicReports.report();
        report
        .columns(
                Columns.columnRowNumberColumn("S No"),
                Columns.column("Accession No", "accessionNo", DataTypes.stringType()),
                Columns.column("Title", "title", DataTypes.stringType()),
                Columns.column("ISBN", "isbn", DataTypes.stringType()),
                Columns.column("Category", "category", DataTypes.stringType()),
                Columns.column("No of Pages", "noOfPages", DataTypes.stringType()),
                Columns.column("Subject", "subject", DataTypes.stringType()),
                Columns.column("Author", "author", DataTypes.stringType()),
                Columns.column("Purchased Date", "purchasedDate", DataTypes.dateType()).setPattern("dd/MM/yyyy"),
                Columns.booleanColumn("Is Book Lost","isBookLost"))
        /*Columns.column("Is Book Lost", "isBookLost", DataTypes.booleanType()),
                Columns.column("Is Book Under Circulation", "isBookUnderCirculation", DataTypes.booleanType()))*/
        .title(
                Components.text("Book Report").
                setHorizontalTextAlignment(HorizontalTextAlignment.CENTER))
        .pageFooter(Components.pageXofY())
        .setDataSource(lstBookDetailsModel);
        try {
            JasperPrint jasperPrintReport=report.toJasperPrint();
            SwingNode swingNode = new SwingNode();
            AnchorPane.setTopAnchor(swingNode,0.0);
            AnchorPane.setBottomAnchor(swingNode,0.0);
            AnchorPane.setLeftAnchor(swingNode,0.0);
            AnchorPane.setRightAnchor(swingNode,0.0);
            JRViewer jrViewer=   new JRViewer(jasperPrintReport);
            SwingUtilities.invokeLater(() ->swingNode.setContent(jrViewer)
                    );
            stackPaneBookHistoryJasperReport.getChildren().add(swingNode);
        } catch (DRException e) {
            e.printStackTrace();
        }
    }

在设置布尔类型的isBookLost的值时,我需要帮助。

0 个答案:

没有答案