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

narcism

Members
  • Posts

    319
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Posts posted by narcism

  1. The only place you could use negative indexes is inside an "Array Slice" expression. In your case that would mean having:

    <field name="street1a" class="java.lang.String">  <property name="net.sf.jasperreports.jsonql.field.expression" value="person.addresses.*[-1:].street1"/></field>[/code]

     

  2. The table interactivity does not work for columns with detail cells that have complex textField expressions.

    For columns that format dates/numbers you could move the pattern at the textField level and choose Blank When NULL  in the textField properties. This way you could only reference the textField in the expression and have the interactivity on for that column. 

  3. This is not a bug. The "AB-CDEF" in "DataItem.AB-CDEF" is not a valid object key in JSONQL, so it needs to be wrapped in quotes and square brackets:

    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("DataItem["AB-CDEF"].GroupData.OGF.FRN")]]></dataSourceExpression>[/code]

    There are more details in the JSONQL description page here: http://jasperreports.sourceforge.net/sample.reference/jsonqldatasource/index.html#jsonql

  4. You need to set the query language to JSONQL/jsonql for "..name" or "$..name" to work.

    This also needs to be matched with the proper field expression like so:

    <queryString language="jsonql">    <![CDATA[..name]]></queryString><field name="name" class="java.lang.String">    <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/>    <fieldDescription><![CDATA[The name]]></fieldDescription></field>[/code]

    This is a special case where the query returns only the leaf nodes of the JSON tree, hence the weird expression. However, if you had "..customer" as your main query, you could use <property name="net.sf.jasperreports.jsonql.field.expression" value="name"/> for your field.

  5. I'm posting only the relevant part, the query and the field mappings:

    <queryString language="jsonql">    <![CDATA[list.*]]></queryString><field name="keyA" class="java.lang.String">    <property name="net.sf.jasperreports.jsonql.field.expression" value="keyA"/>    <fieldDescription><![CDATA[keyA]]></fieldDescription></field><field name="keyB" class="java.lang.String">    <property name="net.sf.jasperreports.jsonql.field.expression" value="keyB"/>    <fieldDescription><![CDATA[keyB]]></fieldDescription></field><field name="keyC" class="java.lang.String">    <property name="net.sf.jasperreports.jsonql.field.expression" value="keyC"/>    <fieldDescription><![CDATA[keyC]]></fieldDescription></field><field name="Title" class="java.lang.String">    <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.title"/>    <fieldDescription><![CDATA[Title]]></fieldDescription></field><field name="Author" class="java.lang.String">    <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.AUTHOR"/>    <fieldDescription><![CDATA[Author]]></fieldDescription></field><field name="Date" class="java.lang.String">    <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.DATE"/>    <fieldDescription><![CDATA[Date]]></fieldDescription></field>[/code]

    Some notes:

    1. If you manually change the query language, from JSON to JSONQL, you also need to adjust the field-level properties to use the proper name: net.sf.jasperreports.jsonql.field.expression

    2. JSON/JSONQL expressions are case sensitive

    3. The JSONQL expression "^{2}.title" implies going up 2 levels from whatever your main query item points to, then select "title"

    4. If your JSON data is part of a bigger JSON tree, then you need to adjust your main query expression from "list.*" to "..list.*" which will look for the "list" key anywhere in the JSON tree

  6. If you are trying to filter inside a field expression, it is not possible. Filtering with values from the same JSON tree it is also not supported.

    In your case you could filter in a subDataSource that you pass to a list like so:

    <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3  --><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="Report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="119c58db-8ae4-4c92-8cd2-16ea09ccb158">    <subDataset name="IndividualsDS" uuid="639a0f17-766f-42f5-bdfe-4157c94becfe">        <field name="givenName" class="java.lang.String">            <property name="net.sf.jasperreports.jsonql.field.expression" value="givenName"/>            <fieldDescription><![CDATA[givenName]]></fieldDescription>        </field>    </subDataset>    <queryString language="jsonql">        <![CDATA[customer]]>    </queryString>    <field name="customerId" class="java.lang.String">        <property name="net.sf.jasperreports.jsonql.field.expression" value="id"/>        <fieldDescription><![CDATA[id]]></fieldDescription>    </field>    <field name="customerName" class="java.lang.String">        <property name="net.sf.jasperreports.jsonql.field.expression" value="name"/>        <fieldDescription><![CDATA[name]]></fieldDescription>    </field>    <field name="customerEngagedPartyId" class="java.lang.String">        <property name="net.sf.jasperreports.jsonql.field.expression" value="engagedParty.id"/>        <fieldDescription><![CDATA[engagedPartyId]]></fieldDescription>    </field>    <background>        <band splitType="Stretch"/>    </background>    <columnHeader>        <band height="30" splitType="Stretch">            <staticText>                <reportElement x="0" y="0" width="180" height="30" uuid="81411315-5690-4f34-a559-3f792e0aad89"/>                <text><![CDATA[Customer Id]]></text>            </staticText>            <staticText>                <reportElement x="180" y="0" width="185" height="30" uuid="1251081f-19ac-46cd-a22e-71159f586b76"/>                <text><![CDATA[Customer Name]]></text>            </staticText>            <staticText>                <reportElement x="365" y="0" width="185" height="30" uuid="b1e0c3a6-a04c-4bdd-99f3-f1a1e612a62c"/>                <text><![CDATA[individual Name]]></text>            </staticText>        </band>    </columnHeader>    <detail>        <band height="30" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="180" height="30" uuid="f6957d1f-1d6b-4855-8ced-af36ea456ff0"/>                <textFieldExpression><![CDATA[$F{customerId}]]></textFieldExpression>            </textField>            <textField>                <reportElement x="180" y="0" width="185" height="30" uuid="2d38c046-a00f-40a0-8750-fd5c0d59018d"/>                <textFieldExpression><![CDATA[$F{customerName}]]></textFieldExpression>            </textField>            <componentElement>                <reportElement x="365" y="0" width="185" height="30" uuid="9e0fdaa7-3cef-4e9c-97a7-715bf5ef499e"/>                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">                    <datasetRun subDataset="IndividualsDS" uuid="72b178d8-0026-4847-9760-ce82b0256e42">                        <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("^.individuals.*(id == "" + $F{customerEngagedPartyId} +  "")")]]></dataSourceExpression>                    </datasetRun>                    <jr:listContents height="30" width="185">                        <textField>                            <reportElement x="0" y="0" width="185" height="30" uuid="ddd6c429-74ee-41ea-9914-f9ff4c44a8f3"/>                            <textFieldExpression><![CDATA[$F{givenName}]]></textFieldExpression>                        </textField>                    </jr:listContents>                </jr:list>            </componentElement>        </band>    </detail></jasperReport>[/code]

     

  7. Same answer as posted here: https://stackoverflow.com/questions/60167856/pass-csv-datasource-from-java-program-to-reports-tables/60185299#60185299

     

    You are reusing the same data source for filling the main dataset and the tables:

    JRCsvDataSource ds = new JRCsvDataSource(inp);..._parameters.put("DS", ds);jasperPrint = JasperFillManager.fillReport(_jasperReport, _parameters, ds);

    This has unpredictable results because of the multiple consumers for the same data source.

    If you have control over the InputStream source like the path to the file you could pass that as a parameter and construct a new instance of JRCsvDataSource for each table that needs it.

  8. If you are able to switch to JSONQL language, you could use a query like: *(id == "bugcorrection")

    The original JSON language is very limited in terms of tree traversal and is meant to be replaced by JSONQL.

×
×
  • Create New...