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

Everything posted by narcism

  1. You cannot use variables in queries. Use parameters instead.
  2. Linking this question to the same one on stackoverflow: https://stackoverflow.com/questions/54104693/dynamic-content-in-text-field-in-jrxml-file
  3. Maybe someone with more experience on mapfish could offer more guidance or ask for it on their product page. Mapfish is not a Tibco Jaspersoft product.
  4. The safest thing to do would be to clone the tableDataSource for each subreport like so: <dataSourceExpression><![CDATA[$P{tableDataSource}.cloneDataSource()]]></dataSourceExpression>[/code]or at least for the second subreport.
  5. Working on the same example that I proposed, you could pass the name as a parameter to the list's dataSet. Here's what you should have instead: The subDataset definition: <subDataset name="TitleDS" uuid="9cece070-b115-4ec6-b614-5f193cbfaced"> <parameter name="pName" class="java.lang.String"/> <field name="text" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="text"/> </field></subDataset>[/code]The list: <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="TitleDS" uuid="4b9df06f-9058-4a75-a704-207d0b3956ed"> <datasetParameter name="pName"> <datasetParameterExpression><![CDATA[$F{name}]]></datasetParameterExpression> </datasetParameter> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("^{2}.title.*(id == " + $F{titleId} + " )")]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="80"> <textField> <reportElement x="0" y="0" width="80" height="30" uuid="92827326-d0e8-4cb7-82ac-76e91fdde255"/> <textFieldExpression><![CDATA[$F{text} + " " + $P{pName}]]></textFieldExpression> </textField> </jr:listContents></jr:list>[/code]and of course, you need to adjust the column header and the detail band to keep only what is relevant.
  6. Regarding *: The wildcard operator is described in the documentation link that you posted. It can be applied to both array and object keys and always produces array structures. Regarding the JavaScript version: Jasperreports relies on Mozilla's Rhino JavaScript engine written in Java, so whatever version they implement that's what we use. Another way to link to the corresponding "title" would imply traveling up the JSON tree and, in a pretty basic usage, could be done like this : <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.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="Report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1ba5dc3f-d678-4af6-9d1f-e1c2734b802e"> <subDataset name="TitleDS" uuid="9cece070-b115-4ec6-b614-5f193cbfaced"> <field name="text" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="text"/> </field> </subDataset> <queryString language="jsonql"> <![CDATA[employee]]> </queryString> <field name="titleId" class="java.lang.Integer"> <propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["title"]]></propertyExpression> </field> <field name="name" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="name"/> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="d41e59d6-4e42-4acb-bbcf-0a53dc7317bd"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="16"/> </textElement> <text><![CDATA[JSONQL Filter]]></text> </staticText> </band> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="80" height="30" forecolor="#000000" backcolor="#ACFCF6" uuid="92e4f28e-99e1-41c8-ab50-ceb655d4ae69"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6e722783-0c23-4671-9044-56acf1c015e6"/> </reportElement> <text><![CDATA[Title]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="80" y="0" width="130" height="30" forecolor="#000000" backcolor="#ACFCF6" uuid="db4e5576-b19c-447a-9a82-de9cf5f9c392"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="aa44f7ad-f18b-4174-8d13-3be39660f86e"/> </reportElement> <text><![CDATA[Name]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <textField> <reportElement x="80" y="0" width="130" height="30" uuid="ce964b5e-9330-4799-b0d1-2367e9a7b1d4"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="aa44f7ad-f18b-4174-8d13-3be39660f86e"/> </reportElement> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> <componentElement> <reportElement x="0" y="0" width="80" height="30" uuid="c54586b0-ff78-4a95-be32-bee9d7228c25"/> <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="TitleDS" uuid="2e473887-cab2-46cd-bd68-4862539a1ec7"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("^{2}.title.*(id == " + $F{titleId} + " )")]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="80"> <textField> <reportElement x="0" y="0" width="80" height="30" uuid="92827326-d0e8-4cb7-82ac-76e91fdde255"/> <textFieldExpression><![CDATA[$F{text}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail></jasperReport>[/code]
  7. In this case you can actually use the data from your query in the main report. I had in mind a different scenario when I mentioned that.
  8. Things are not all that different between JSON/JSONQL and JDBC data sources in terms of data source processing. With subreports, as you might already know, it is about how the main data source relates to the subreport's data source: is it the same, just a subset or is it completely different? And these things matter because when reusing the same data source inside a subreport, it might completly exhaust it and the main report would be left without any more records to process. In your case the main dataset consists of 9 items from the "sitojs" array, produced by your query: <queryString language="json"> <![CDATA[sitojs]]></queryString> which means that the detail band will be repeated 9 times with your subreport. To fix this, you could: leave the main report's query emptyeither leave your subreport inside the detail band or move it to the summary band, andset it's dataSourceExpression to:<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("sitojs.taking_hostel")]]></dataSourceExpression>and you will get the expected result:
  9. Posting some sample JSON data might speed things up a little.
  10. This is how it works with Data Adapters. The server runs the Data Adapter twice: Once in order to populate the default values for the input controls. And this is where it fails and, to go past this, you need to set the default expression for your parameters that have input controls associated.And once more to produce the report output based on your input control values
  11. Linking this to stackoverflow: https://stackoverflow.com/questions/53206907/how-to-change-color-of-element-with-color-from-field with accepted answer: You could use Report Design propertyExpressions like so: <rectangle> <reportElement mode="Opaque" x="80" y="50" width="400" height="50" uuid="e0f482d1-4ada-4bec-9fe2-989649399b1e"> <propertyExpression name="net.sf.jasperreports.style.forecolor"><![CDATA[$F{color}]]></propertyExpression> <propertyExpression name="net.sf.jasperreports.style.backcolor"><![CDATA[$F{backcolor}]]></propertyExpression> </reportElement></rectangle>[/code]You could check out more style properties in the JasperReports Configuration Reference Page, in the Report Design section
  12. https://community.jaspersoft.com/questions/1108701/printed-json-values
  13. See Edit #2 for all possible solutions
  14. First you should get somehow familiar with the REST API that is described here: https://community.jaspersoft.com/documentation/tibco-jasperreports-server-rest-api-reference/v710/rest-api-overview Based on that API, there is this Java client created by Jaspersoft: https://github.com/Jaspersoft/jrs-rest-java-client. The Readme there covers a lot of topics. If you're not into a Java-based solution you could use the API directly. My answer here: https://stackoverflow.com/a/37441567/5882963 covers a similar topic to yours but starts off with how to pass XML data to sample report and then how to modify the report in order to pass JSON data.
  15. To make the JSON traversal easier, since you are in control of its generation, why don't you build something like this instead?: { "order":"000000", "valueorder":"270.00", "payment":"CRED CARD 2X", "date":"2017-03-17", "nextpayments": [ { "date": "17/03/2017", "value": "R$u00a0135,00" }, { "date": "02/05/2017", "value": "R$u00a0135,00" } ] } This way the data is logically grouped and easier to display.
  16. I got the sense of what you are trying to achieve, but without specific info I cannot guide you through a proper solution. What calculations do you perform on your json data? How does "nextpayments" relate to "valuenextpayment". I requested that you edit your initial question with proper information so that others could benefit from this.
  17. Please add more info to your question with sample data: how your json looks like, how you feed it to your report, what report output you expect
  18. You could check out my answer here: https://stackoverflow.com/a/37441567/5882963 It contains a sample JRXML that starts with XML data and then about JSON. In essence you need to pass the JSON data as a String parameter and then convert it to an InputStream and construct a special parameter that JasperReports picks up and fills the report: <parameter name="jsonString" class="java.lang.String"> <defaultValueExpression><![CDATA["{"a": [ {"b": { "val": "val1"}}, {"b": { "val": "val2" }}]}"]]></defaultValueExpression></parameter><parameter name="JSON_INPUT_STREAM" class="java.io.InputStream"> <defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{jsonString}.getBytes("UTF-8"))]]></defaultValueExpression></parameter>Edit: With a JSON like this: { "order":"000000", "valueorder":"270.00", "payment":"CRED CARD 2X", "date":"2017-03-17", "nextpayment":[ "17/03/2017", "02/05/2017" ], "valuenextpayment":[ "R$u00a0135,00", "R$u00a0135,00"]}your report would look like this: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.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="Report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="16882c94-641b-47b6-bd2f-675edbc1f15a"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/> <subDataset name="NextPaymentDateDataset" uuid="5337e69f-16e4-447d-a9e7-fbe6d25a479f"> <field name="item" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> <fieldDescription><![CDATA[The Item in the Dates Array]]></fieldDescription> </field> </subDataset> <subDataset name="NextPaymentValueDataset" uuid="5337e69f-16e4-447d-a9e7-fbe6d25a479f"> <field name="item" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> <fieldDescription><![CDATA[The Item in the Values Array]]></fieldDescription> </field> </subDataset> <parameter name="jsonString" class="java.lang.String"> <defaultValueExpression><![CDATA["{n" + " "order": "000000",n" + " "valueorder": "270.00",n" + " "payment": "CRED CARD 2X",n" + " "date": "2017-03-17",n" + " "nextpayment": [n" + " "17/03/2017",n" + " "02/05/2017"n" + " ],n" + " "valuenextpayment": [n" + " "R$\u00a0135,00",n" + " "R$\u00a0135,00"n" + " ]n" + "}"]]></defaultValueExpression> </parameter> <parameter name="JSON_INPUT_STREAM" class="java.io.InputStream"> <defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{jsonString}.getBytes("UTF-8"))]]></defaultValueExpression> </parameter> <queryString language="jsonql"> <![CDATA[]]> </queryString> <field name="order" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="order"/> <fieldDescription><![CDATA[order]]></fieldDescription> </field> <field name="valueorder" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="valueorder"/> <fieldDescription><![CDATA[valueorder]]></fieldDescription> </field> <field name="payment" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="payment"/> <fieldDescription><![CDATA[payment]]></fieldDescription> </field> <field name="date" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="date"/> <fieldDescription><![CDATA[date]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="33c1adf9-dc58-4d35-a409-72de3d4f0347"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[unrelated JSON arrays]]></text> </staticText> </band> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="80" height="30" backcolor="#BEFADB" uuid="5258fbf3-575f-486e-bede-26e83ec791a5"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b5c10f8-8390-4a95-a707-2f267d64349a"/> </reportElement> <text><![CDATA[order]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="80" y="0" width="90" height="30" backcolor="#BEFADB" uuid="464a7d52-1801-4d67-9cda-c4b2d2e4526b"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a223b8db-9803-4257-baf6-cfbc758b6950"/> </reportElement> <text><![CDATA[valueorder]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="170" y="0" width="100" height="30" backcolor="#BEFADB" uuid="c179e19a-efa9-4d27-947c-84b14d2639aa"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="166b5682-4aab-4c8a-b7d3-4e7b4be84db6"/> </reportElement> <text><![CDATA[payment]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="270" y="0" width="80" height="30" backcolor="#BEFADB" uuid="cb1829b9-c782-42a7-a3f4-0126db20cc6a"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[order date]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="350" y="0" width="100" height="30" backcolor="#BEFADB" uuid="628c20fa-bbc9-43ea-8aa4-1486bf518e38"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[next payment date]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="450" y="0" width="100" height="30" backcolor="#BEFADB" uuid="2b4c49a7-1984-48d4-aa92-9a6d859feda8"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[next payment value]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <textField> <reportElement x="0" y="0" width="80" height="30" uuid="27c8ae6d-def5-4abd-b691-d350fd92c719"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b5c10f8-8390-4a95-a707-2f267d64349a"/> </reportElement> <textFieldExpression><![CDATA[$F{order}]]></textFieldExpression> </textField> <textField> <reportElement x="80" y="0" width="90" height="30" uuid="94342e9b-d545-441c-9350-9179e4cc2530"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a223b8db-9803-4257-baf6-cfbc758b6950"/> </reportElement> <textFieldExpression><![CDATA[$F{valueorder}]]></textFieldExpression> </textField> <textField> <reportElement x="170" y="0" width="100" height="30" uuid="8e5286de-d8ac-43a5-bc70-936d3b59db7d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="166b5682-4aab-4c8a-b7d3-4e7b4be84db6"/> </reportElement> <textFieldExpression><![CDATA[$F{payment}]]></textFieldExpression> </textField> <textField> <reportElement x="270" y="0" width="80" height="30" uuid="835948f8-45ba-4c4a-8306-c6ad70214ba0"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression> </textField> <componentElement> <reportElement x="350" y="0" width="100" height="30" uuid="89f3fd2c-4be0-466c-9b22-c749e8b69d42"/> <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="NextPaymentDateDataset" uuid="964313c4-37e8-408f-adca-e6c436a76d4b"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("nextpayment")]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="100"> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="143efbb1-c95a-49bf-adff-a618b5518c75"/> <textFieldExpression><![CDATA[$F{item}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> <componentElement> <reportElement x="450" y="0" width="100" height="30" uuid="d569f091-7eac-44db-8e12-d83837b0ddae"/> <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="NextPaymentValueDataset" uuid="7e2aa9c7-6d1f-4722-8f78-1f52da462473"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("valuenextpayment")]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="100"> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="a71eae3c-0bb7-4286-a80c-714a59d9f869"/> <textFieldExpression><![CDATA[$F{item}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>and produce the following output: With a JSON like the one I've reccommended: { "order":"000000", "valueorder":"270.00", "payment":"CRED CARD 2X", "date":"2017-03-17", "nextpayments": [ { "date": "17/03/2017", "value": "R$u00a0135,00" }, { "date": "02/05/2017", "value": "R$u00a0135,00" } ]}the JRXML will be more compact, with no lists and additional subDatasets: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.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="Report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="16882c94-641b-47b6-bd2f-675edbc1f15a"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/> <parameter name="jsonString" class="java.lang.String"> <defaultValueExpression><![CDATA["{n" + " "order":"000000",n" + " "valueorder":"270.00",n" + " "payment":"CRED CARD 2X",n" + " "date":"2017-03-17",n" + " "nextpayments": [n" + " {n" + " "date": "17/03/2017",n" + " "value": "R$\u00a0135,00" n" + " }, n" + " {n" + " "date": "02/05/2017",n" + " "value": "R$\u00a0135,00" n" + " }n" + " n" + " ]n" + "}"]]></defaultValueExpression> </parameter> <parameter name="JSON_INPUT_STREAM" class="java.io.InputStream"> <defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{jsonString}.getBytes("UTF-8"))]]></defaultValueExpression> </parameter> <queryString language="jsonql"> <![CDATA[nextpayments.*]]> </queryString> <field name="nextPaymentDate" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="date"/> <fieldDescription><![CDATA[next payment date]]></fieldDescription> </field> <field name="nextPaymentValue" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="value"/> <fieldDescription><![CDATA[next payment value]]></fieldDescription> </field> <field name="order" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.order"/> <fieldDescription><![CDATA[order]]></fieldDescription> </field> <field name="valueorder" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.valueorder"/> <fieldDescription><![CDATA[valueorder]]></fieldDescription> </field> <field name="payment" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.payment"/> <fieldDescription><![CDATA[payment]]></fieldDescription> </field> <field name="orderDate" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.date"/> <fieldDescription><![CDATA[order date]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="33c1adf9-dc58-4d35-a409-72de3d4f0347"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[Restructured JSON]]></text> </staticText> </band> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="80" height="30" backcolor="#BEFADB" uuid="5258fbf3-575f-486e-bede-26e83ec791a5"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b5c10f8-8390-4a95-a707-2f267d64349a"/> </reportElement> <text><![CDATA[order]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="80" y="0" width="90" height="30" backcolor="#BEFADB" uuid="464a7d52-1801-4d67-9cda-c4b2d2e4526b"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a223b8db-9803-4257-baf6-cfbc758b6950"/> </reportElement> <text><![CDATA[valueorder]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="170" y="0" width="100" height="30" backcolor="#BEFADB" uuid="c179e19a-efa9-4d27-947c-84b14d2639aa"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="166b5682-4aab-4c8a-b7d3-4e7b4be84db6"/> </reportElement> <text><![CDATA[payment]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="270" y="0" width="80" height="30" backcolor="#BEFADB" uuid="cb1829b9-c782-42a7-a3f4-0126db20cc6a"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[order date]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="350" y="0" width="100" height="30" backcolor="#BEFADB" uuid="628c20fa-bbc9-43ea-8aa4-1486bf518e38"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[next payment date]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="450" y="0" width="100" height="30" backcolor="#BEFADB" uuid="2b4c49a7-1984-48d4-aa92-9a6d859feda8"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[next payment value]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <textField> <reportElement x="0" y="0" width="80" height="30" uuid="27c8ae6d-def5-4abd-b691-d350fd92c719"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b5c10f8-8390-4a95-a707-2f267d64349a"/> </reportElement> <textFieldExpression><![CDATA[$F{order}]]></textFieldExpression> </textField> <textField> <reportElement x="80" y="0" width="90" height="30" uuid="94342e9b-d545-441c-9350-9179e4cc2530"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a223b8db-9803-4257-baf6-cfbc758b6950"/> </reportElement> <textFieldExpression><![CDATA[$F{valueorder}]]></textFieldExpression> </textField> <textField> <reportElement x="170" y="0" width="100" height="30" uuid="8e5286de-d8ac-43a5-bc70-936d3b59db7d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="166b5682-4aab-4c8a-b7d3-4e7b4be84db6"/> </reportElement> <textFieldExpression><![CDATA[$F{payment}]]></textFieldExpression> </textField> <textField> <reportElement x="270" y="0" width="80" height="30" uuid="835948f8-45ba-4c4a-8306-c6ad70214ba0"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <textFieldExpression><![CDATA[$F{orderDate}]]></textFieldExpression> </textField> <textField> <reportElement x="350" y="0" width="100" height="30" uuid="7bd69460-736a-4f02-b7c6-7aea7f6ae3e4"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="cdbb795a-808b-4e99-8f21-6666b54aa457"/> </reportElement> <textFieldExpression><![CDATA[$F{nextPaymentDate}]]></textFieldExpression> </textField> <textField> <reportElement x="450" y="0" width="100" height="30" uuid="770eaeb3-2c1e-4741-afee-4dc5b6c13058"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="dfbc2e2f-40e6-4809-b2fe-aa7033dbd0ea"/> </reportElement> <textFieldExpression><![CDATA[$F{nextPaymentValue}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>and produce the following output: If you don't want repeating values, select all the textfields except the ones containing $F{nextPaymentDate} and $F{nextPaymentValue} and uncheck the "Print Repeated Values" in the Properties Tab Edit #2: With a JSON like: { "1786616": { "order": "1786616", "valueorder": "330.00", "payment": "CARTu00c3O DE CRu00c9DITO", "date": "2017-02-13" }, "1786681": { "order": "1786681", "valueorder": "330.00", "payment": "CARTu00c3O CRu00c9DITO 4C/ACRu00c9SCIMO)", "date": "2017-02-13", "nextpayments": [{ "date": "13/02/2017", "value": "R$u00a082,50" }, { "date": "28/03/2017", "value": "R$u00a082,50" }, { "date": "11/05/2017", "value": "R$u00a082,50" }, { "date": "22/06/2017", "value": "R$u00a082,50" } ] }}If you are only interested in orders that have the "nextpayments" key, you could modify the above sample's query from: <queryString language="jsonql"> <![CDATA[nextpayments.*]]></queryString>to: <queryString language="jsonql"> <![CDATA[.*.nextpayments.*]]></queryString>But if you also want the order that does not have the "nextpayments" key you need to resort to a list-based solution, something similar to the first sample. Here's a sample JRXML: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.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="Report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="16882c94-641b-47b6-bd2f-675edbc1f15a"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/> <subDataset name="NextPaymentsDateDataset" uuid="5337e69f-16e4-447d-a9e7-fbe6d25a479f"> <field name="nextPaymentDate" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="date"/> </field> <field name="nextPaymentValue" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="value"/> </field> </subDataset> <parameter name="jsonString" class="java.lang.String"> <defaultValueExpression><![CDATA["{n" + " "1786616": {n" + " "order": "1786616",n" + " "valueorder": "330.00",n" + " "payment": "CART\u00c3O DE CR\u00c9DITO",n" + " "date": "2017-02-13"n" + " },n" + " "1786681": {n" + " "order": "1786681",n" + " "valueorder": "330.00",n" + " "payment": "CART\u00c3O CR\u00c9DITO 4C\/ACR\u00c9SCIMO)",n" + " "date": "2017-02-13",n" + " "nextpayments": [{n" + " "date": "13\/02\/2017",n" + " "value": "R$\u00a082,50"n" + " },n" + " {n" + " "date": "28\/03\/2017",n" + " "value": "R$\u00a082,50"n" + " },n" + " {n" + " "date": "11\/05\/2017",n" + " "value": "R$\u00a082,50"n" + " },n" + " {n" + " "date": "22\/06\/2017",n" + " "value": "R$\u00a082,50"n" + " }n" + " ]n" + " }n" + "}"]]></defaultValueExpression> </parameter> <parameter name="JSON_INPUT_STREAM" class="java.io.InputStream"> <defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{jsonString}.getBytes("UTF-8"))]]></defaultValueExpression> </parameter> <queryString language="jsonql"> <![CDATA[.*]]> </queryString> <field name="order" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="order"/> <fieldDescription><![CDATA[order]]></fieldDescription> </field> <field name="valueorder" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="valueorder"/> <fieldDescription><![CDATA[valueorder]]></fieldDescription> </field> <field name="payment" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="payment"/> <fieldDescription><![CDATA[payment]]></fieldDescription> </field> <field name="date" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="date"/> <fieldDescription><![CDATA[date]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="33c1adf9-dc58-4d35-a409-72de3d4f0347"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[Variable JSON arrays]]></text> </staticText> </band> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="80" height="30" backcolor="#BEFADB" uuid="5258fbf3-575f-486e-bede-26e83ec791a5"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b5c10f8-8390-4a95-a707-2f267d64349a"/> </reportElement> <text><![CDATA[order]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="80" y="0" width="90" height="30" backcolor="#BEFADB" uuid="464a7d52-1801-4d67-9cda-c4b2d2e4526b"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a223b8db-9803-4257-baf6-cfbc758b6950"/> </reportElement> <text><![CDATA[valueorder]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="170" y="0" width="100" height="30" backcolor="#BEFADB" uuid="c179e19a-efa9-4d27-947c-84b14d2639aa"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="166b5682-4aab-4c8a-b7d3-4e7b4be84db6"/> </reportElement> <text><![CDATA[payment]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="270" y="0" width="80" height="30" backcolor="#BEFADB" uuid="cb1829b9-c782-42a7-a3f4-0126db20cc6a"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[order date]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="350" y="0" width="100" height="30" backcolor="#BEFADB" uuid="628c20fa-bbc9-43ea-8aa4-1486bf518e38"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[next payment date]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="450" y="0" width="100" height="30" backcolor="#BEFADB" uuid="2b4c49a7-1984-48d4-aa92-9a6d859feda8"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <text><![CDATA[next payment value]]></text> </staticText> </band> </columnHeader> <detail> <band height="35" splitType="Stretch"> <textField> <reportElement x="0" y="0" width="80" height="30" uuid="27c8ae6d-def5-4abd-b691-d350fd92c719"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b5c10f8-8390-4a95-a707-2f267d64349a"/> </reportElement> <textFieldExpression><![CDATA[$F{order}]]></textFieldExpression> </textField> <textField> <reportElement x="80" y="0" width="90" height="30" uuid="94342e9b-d545-441c-9350-9179e4cc2530"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a223b8db-9803-4257-baf6-cfbc758b6950"/> </reportElement> <textFieldExpression><![CDATA[$F{valueorder}]]></textFieldExpression> </textField> <textField> <reportElement x="170" y="0" width="100" height="30" uuid="8e5286de-d8ac-43a5-bc70-936d3b59db7d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="166b5682-4aab-4c8a-b7d3-4e7b4be84db6"/> </reportElement> <textFieldExpression><![CDATA[$F{payment}]]></textFieldExpression> </textField> <textField> <reportElement x="270" y="0" width="80" height="30" uuid="835948f8-45ba-4c4a-8306-c6ad70214ba0"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b7a27377-1e06-43c4-afab-840efea597f3"/> </reportElement> <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression> </textField> <componentElement> <reportElement x="350" y="0" width="200" height="30" uuid="89f3fd2c-4be0-466c-9b22-c749e8b69d42"/> <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="NextPaymentsDateDataset" uuid="40421d98-9a67-451f-afe3-d835f0deaeaf"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("nextpayments")]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="200"> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="143efbb1-c95a-49bf-adff-a618b5518c75"/> <textFieldExpression><![CDATA[$F{nextPaymentDate}]]></textFieldExpression> </textField> <textField> <reportElement x="100" y="0" width="100" height="30" uuid="16ce45fb-1631-4e0b-9875-9427f6544c7e"/> <textFieldExpression><![CDATA[$F{nextPaymentValue}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>with this output:
  19. Setting the *net.sf.jasperreport.data.adapter* property should suffice. It will be automatically picked up by Studio. I am also using version 6.6.0 CE final but not receiving any NPEs. Not sure I can help on that anymore unless I reproduce it locally.
  20. This is one of the limitations of the JSON based querys. Try switching to JSONQL and set a filter expression like: (CustomerID == "test.1") If you are using the northwind.json file from the jsondatasource sample a query to select and filter the Orders would look like so: Northwind.Orders.*(CustomerID == "test.1") More info on JSONQL could be found here: http://jasperreports.sourceforge.net/sample.reference/jsonqldatasource/index.html#jsonql M
  21. You get that message because your PROJECT.jrxml does not compile. The one that you linked contains an invalid subreport expression: <subreportExpression><![CDATA[in properties>subreport>Expression "USER.jrxml"]]></subreportExpression>[/code]The expression should be just "USER.jrxml". Make sure you recompile each modified subreport or choose Project > Build Automatically to have Studio do it for you after saving each modified file. Once you get past the above issue: 1. Remove the connectionExpression that passes $P{REPORT_CONNECTION}. It has effect only for JDBC connections, which you don't have. 2. In CUSTOMER.jrxml set this dataSourceExpression: <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("projectReportDtos")]]></dataSourceExpression>[/code]3. In PROJECT.jrxml set this dataSourceExpression: <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("userReportDtos")]]></dataSourceExpression>[/code]4. Optionally, you may want to delete the unused bands and/or shrink the detail bands in order to reduce the white space between records.
  22. Yes, that NPE is caused by that. Setting the Evaluation Time to "Early" for each parameter involved in URL creation should fix this. Regarding the XML file name, I'm not sure why there's no control over the naming, but the report will be linked to it if. You could check that by opening it from the Repository Explorer view instead of the workspace.
  23. This should be about filtering inside your query. But unfortunately the JSON based one is very limited in that respect. However, you could switch to JSONQL query instead of JSON (simply by replacing them in the JRXML) and have this dataSourceExpressoin for your table dataset: <datasetRun subDataset="Dataset1" uuid="534bcfd4-5c3f-4d52-a798-943b5cdb9d36"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("scoringFinFactorList.*(code *= "FR_01_")")]]></dataSourceExpression></datasetRun>[/code]Your actual subdataset query is: scoringFinFactorList.*(code *= "FR_01_") and translates to: select all the children of the scoringFinFactorList array with the code key containing FR_01_
×
×
  • Create New...