Jump to content
We've recently updated our Privacy Statement, available here ×

Tom C

Jaspersoft Staff
  • Posts

    453
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Downloads

Posts posted by Tom C

  1. import net.sf.jasperreports.engine.JRDataSource;
    import net.sf.jasperreports.engine.JREmptyDataSource;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.util.JRLoader;
    import net.sf.jasperreports.view.JasperViewer;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.HashMap;
    import java.util.Map;

    public class JasperReportWithSubreports {
        public static void main(String[] args) {
            // Create a connection to your database
            Connection connection = createDatabaseConnection();

            // Load the compiled main Jasper report (.jasper file)
            JasperReport mainReport = loadCompiledReport("path/to/main/report.jasper");

            // Load the compiled subreport (.jasper file)
            JasperReport subReport = loadCompiledReport("path/to/sub/report.jasper");

            // Set parameters for the main report
            Map<String, Object> parameters = new HashMap<>();
            parameters.put("ReportTitle", "Sample Report");
            parameters.put("CompanyName", "ABC Corp");
            parameters.put("subReportParameter", subReport); // Pass the subreport to the parameter

            // Fill the main report with data using a JRDataSource implementation
            JRDataSource dataSource = createDataSource();
            JasperPrint jasperPrint = null;
            try {
                jasperPrint = JasperFillManager.fillReport(mainReport, parameters, dataSource);
            } catch (Exception e) {
                e.printStackTrace();
            }

            // Display the report in a viewer (optional)
            if (jasperPrint != null) {
                JasperViewer.viewReport(jasperPrint, false);
            }

            // Close the database connection
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        // ... Same createDatabaseConnection, createDataSource methods as before ...

        private static JasperReport loadCompiledReport(String reportFilePath) {
            JasperReport jasperReport = null;
            try {
                jasperReport = (JasperReport) JRLoader.loadObjectFromFile(reportFilePath);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return jasperReport;
        }
    }
     

  2. You can use a table element with print when condition on the column to hide it; and the rest of the columns to its right will get auto moved to the left to place its void.

     

    The print when condition however needs to be determined before the table elements are being laid out. In addition, the width of the report field is fixed at the design time therefore you cannot expand the field width dynamically at the run time. (The stretch can only be applied to the report field height, not the width when its content is overflown).   

  3. The content of jireportjobparameter.parameter_value field is a Java object that only the JRS class method can decipher, such as (with bytea 'escape' encoding):

    25435500sr00java.util.ArrayListx201322231307a23500I00sizexp000000w000000t001t003x
     

    Instead of attempting with SQL query to encode, you should use JRS REST call report job service to get the listed parameter values from the job definition:

     

    GET http://<host>:<port>/jasperserver[-pro]/rest_v2/jobs/<jobID>/
     

    From the return of the REST call, you should see the parameter information in the json job descriptor, something like:

     

        "source": {
            "reportUnitURI": "/public/TTC/Slack/20230602/Cascading_multi_select_topic",
            "parameters": {
                "parameterValues": {
                    "Country_multi_select": [
                        "USA"
                    ],
                    "Cascading_name_single_select": [
                        "A & U Stalker Telecommunications, Inc"
                    ],
                    "Cascading_state_multi_select": [
                        "CA",
                        "OR"
                    ]
                }
            }
        },
    ---------------------------------------------------------

    For more information, please refer to "TIBCO JasperReports® Server REST API Reference" document.

     

    https://community.jaspersoft.com/documentation/tibco-jasperreports-server-rest-api-reference/v790/jobs-service#Viewing_a_Job_Definition

     

  4. JasperReports engine (JRL) is a Java application, not a scripting application, therefore you cannot use string substitution directly in the text string.

    What you can do, however is to use Java string substitution class method to achieve your goal:

    $F{INTRODUCTION}.replace("$F{NAME}", $F{NAME})

    untitled_0.thumb.png.52c8eaff6716abc810530a9275863c13.png

  5. Issue:

    1) Report "has a Multi select parameter which is String datatype", such as ["USA",...]

    2) "Input control : It is single select query", therefore the value is "USA".

     

    Problem:

    Can not use single select input to feed report collection parameter. "USA" -->  ["USA",...], incorrect.

     

    Resolution:

    Use MULTI select input control instead.  ["USA",...] -->  ["USA",...]

  6. "one OCPU and 1GB of RAM"?

     

    I cannot imagine a machine with that configuration can do any meaningful data processing work in 2022. 

    FYI, 

    Windows 11 has the following minimum hardware requirements:

    • Processor: 1 gigahertz (GHz) or faster with two or more cores on a compatible 64-bit processor or system on a chip (SoC).
    • RAM: 4 gigabytes (GB) or greater.

    Refer to https://support.microsoft.com/en-us/windows/windows-11-system-requirements-86c11283-ea52-4782-9efd-7674389a7ba3

     

    And the recommended minimum system requirements for Ubuntu desktop edition is 

    • 2 GHz dual core processor
    • 4 GiB RAM (system memory)

    Refer to https://help.ubuntu.com/community/Installation/SystemRequirements

     

    This is just to get the OS up and running and we are not talking about running a web application server (Apache-Tomcat) and database (PostgreSQL) on this machine to support JasperReports Server (JRS) web application.

     

    People can spend $300 to buy a Lenovo laptop with 2 core CPU and 4G RAM from Costco and meet that requirement. 

     

    https://www.costco.com/lenovo-ideapad-1-15.6%22-laptop---intel-pentium-silver-n6000---1080p---windows-11-s-mode---microsoft-365-personal-(1-year-subscription).product.100858024.html  

  7. Only the commercial edition of JasperReports Server (JRS) has the ad hoc feature which allows users to create an ad hoc view report directly in the JRS web flow Ad Hoc designer. Free community edition does not offer this feature.

    The JRS commercial edition (AKA "professional" edition) has pro charts, dashboard, OLAP, multi-tenancy, and audit components that the open source community edition does not offer. 

    The JRS pro installation package comes with the full feature of the product. Depending on the licensing contract (how much users are willing to pay), users can get either a Professional license or an Enterprise license to activate the multi-tenancy and audit features. The rest of the pro features are available to both types of the JRS pro licenses.

    Hope this clarifies the issue.

       

     

  8. This is a SQL query issue that has nothing to do with our product. You need to use joins to lift data from multiple tables, something like

    select t1.a, my_function(t1.p1,t2.p2), t2.b, DECODE(t1.C, '1', 'M.', '2', 'Mme')from tab1 t1inner join tab2 t2 on t1.id = t2.id[/code]

    Please take some SQL training classes (and Java classes) to get yourself familiar with the technology to use our product effectively. You may find this YouTube video useful and helpful:

    https://www.youtube.com/watch?v=rocjHUQf5n0

    Good luck and happy coding. :)

     

    • Like 1
  9. <?xml version="1.0" encoding="UTF-8"?>
    <!-- Created with Jaspersoft Studio version 8.0.1.final using JasperReports Library version 6.11.0  -->
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="demo20220303" pageWidth="612" pageHeight="792" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6a28a568-5cd4-4fc1-9e28-015213d63b58">
        <parameter name="Input String" class="java.lang.String">
            <defaultValueExpression><![CDATA["apple, banana, strawberry, lemon"]]></defaultValueExpression>
        </parameter>
        <queryString>
            <![CDATA[]]>
        </queryString>
        <title>
            <band height="79" splitType="Stretch">
                <textField>
                    <reportElement mode="Opaque" x="0" y="0" width="570" height="30" backcolor="#FFFF00" uuid="e4fc6e91-9a90-4b32-98e2-7355e3b81afe"/>
                    <textFieldExpression><![CDATA["INPUT STRING: "+$P{Input String}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement mode="Opaque" x="1" y="40" width="570" height="30" backcolor="#33FF00" uuid="323b73b5-269c-42ad-a1ad-a6689316fc8c"/>
                    <textFieldExpression><![CDATA["Modified String: "+$P{Input String}.replaceFirst(",([^,]+)$", " and$1")]]></textFieldExpression>
                </textField>
            </band>
        </title>
    </jasperReport>

     

    screenshot_2011.thumb.png.de5334a917e668e2cc90335e1e2dbe18.png

×
×
  • Create New...