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. The horizontal display can be achieved like this with lists: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 --><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_v1" pageWidth="595" pageHeight="842" columnWidth="90" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="86523aef-3262-499e-ae57-66e5dabd4218"> <subDataset name="ListDataSet" uuid="fb812d2a-cb63-473c-b7d3-149977476dd0"> <field name="val" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> </field> </subDataset> <queryString language="jsonql"> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="4014c1c1-e6a1-4d22-a50f-6cedeac55ead"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[Horizontal Display]]></text> </staticText> </band> </title> <pageHeader> <band height="30" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="30"> <staticText> <reportElement mode="Opaque" x="360" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="ec8aaa95-0f7b-42cf-b858-eca1c1f6938d"/> <text><![CDATA[Remark]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="180" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="645a5553-e3bd-4949-92a9-a56ab0f4f31e"/> <text><![CDATA[Fax]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="0" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="82279926-fcc9-4111-a8ba-d215eddc5b18"/> <text><![CDATA[Name]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="90" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="243d1437-6676-49de-bb75-1f3341716646"/> <text><![CDATA[Tel]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="270" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="50b884d0-5d0f-40e7-ab35-e6f26f870ca6"/> <text><![CDATA[Address]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <componentElement> <reportElement x="0" y="0" width="450" height="30" uuid="887dc258-2eac-4492-ae69-f9b2ffd1faee"> <property name="com.jaspersoft.studio.unit.CONTENTS.width" value="px"/> </reportElement> <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="Horizontal"> <datasetRun subDataset="ListDataSet" uuid="1316cfd7-fe59-440f-a155-501914c00056"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource()]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="90"> <textField> <reportElement x="0" y="0" width="90" height="30" uuid="4ee2d6b3-c681-433f-a170-4bb31697de58"/> <textFieldExpression><![CDATA[$F{val}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>The preview: The vertical display can be done this way, with nested lists: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 --><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_v2" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="90" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="86523aef-3262-499e-ae57-66e5dabd4218"> <subDataset name="HorizontalListDataSet" uuid="fb812d2a-cb63-473c-b7d3-149977476dd0"/> <subDataset name="VerticalListDataSet" uuid="86686d59-46df-43f1-b2bf-82998d8569be"> <field name="val" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> </field> </subDataset> <queryString language="jsonql"> <![CDATA[]]> </queryString> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="4014c1c1-e6a1-4d22-a50f-6cedeac55ead"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[Vertical Display]]></text> </staticText> </band> </title> <pageHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="90" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="243d1437-6676-49de-bb75-1f3341716646"/> <text><![CDATA[Tel]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="0" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="82279926-fcc9-4111-a8ba-d215eddc5b18"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <property name="com.jaspersoft.studio.unit.spacingBefore" value="pixel"/> </reportElement> <textElement> <paragraph leftIndent="0"/> </textElement> <text><![CDATA[Name]]></text> </staticText> </band> </pageHeader> <summary> <band height="50"> <componentElement> <reportElement x="0" y="0" width="180" height="30" uuid="887dc258-2eac-4492-ae69-f9b2ffd1faee"> <property name="com.jaspersoft.studio.unit.CONTENTS.width" value="px"/> </reportElement> <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="Horizontal"> <datasetRun subDataset="HorizontalListDataSet" uuid="1316cfd7-fe59-440f-a155-501914c00056"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource("^")]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="90"> <componentElement> <reportElement x="0" y="0" width="90" height="30" uuid="3ba51777-567a-495e-b631-ac03510fdbb0"/> <jr:list printOrder="Vertical"> <datasetRun subDataset="VerticalListDataSet" uuid="c4c4534b-2081-4903-84f2-42621c022a3c"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource()]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="90"> <textField> <reportElement x="0" y="0" width="90" height="30" uuid="4aab6768-2a75-4d88-995a-45a9af3732d1"/> <textFieldExpression><![CDATA[$F{val}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </jr:listContents> </jr:list> </componentElement> </band> </summary></jasperReport>The preview:
  2. Yes, it's possible. You could checkout the visualize.js guide on creating pagination controls: https://community.jaspersoft.com/documentation/tibco-jasperreports-server-visualizejs-guide/v62/api-reference-report#Creating_Pagination_NextPrevious
  3. Your answer can be found in this stackoverflow post: https://stackoverflow.com/a/37441567/5882963 in the 'EDIT' section. In essence, you could use two parameters, one with the actual data and the other specific to JasperReports internals: <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>[/code]the query language can be either JSONQL or JSON.
  4. The easiest way to accomplish your task would be to use the newer JSONQL language. It has proper support starting with Jaspersoft Studio 6.4.0. With JSONQL you usually don't need subreports for deep JSON tree traversals. For a JSON like this: { "invoice": [{ "number": 1234, "items": [{ "name": "Product name1", "value": "10.00" }, { "name": "Product name2", "value": "11.00" } ] }]}[/code]this is what your report might look like: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 --><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="b737898e-fb0a-469b-8c73-efd525619536"> <queryString language="jsonql"> <![CDATA[..items.*]]> </queryString> <field name="invoiceNo" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^^.number"/> <fieldDescription><![CDATA[invoice No]]></fieldDescription> </field> <field name="name" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="name"/> <fieldDescription><![CDATA[Product Name]]></fieldDescription> </field> <field name="value" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="value"/> <fieldDescription><![CDATA[Product Value]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="16ef1203-859b-48c4-bc78-61fa44c46903"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[basic JSONQL Traversal]]></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="185" height="30" backcolor="#C3F3FA" uuid="ed0f872a-643f-4b75-8ab1-7eb5d379541f"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbb61538-1d5b-4e54-864c-314aa6a4ac87"/> </reportElement> <text><![CDATA[invoice No]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="185" y="0" width="185" height="30" backcolor="#C3F3FA" uuid="505d42c7-ada6-42be-88dd-913efc637f58"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="5bcddd82-bece-48bf-8d64-98092796d145"/> </reportElement> <text><![CDATA[Product Name]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="370" y="0" width="185" height="30" backcolor="#C3F3FA" uuid="a2439544-1784-4ef9-b216-2e862253ad72"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="645fb340-d87c-44ca-bfab-31d97554b215"/> </reportElement> <text><![CDATA[Product Value]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <textField> <reportElement isPrintRepeatedValues="false" x="0" y="0" width="185" height="30" uuid="066ee7e6-9153-487b-b599-e7dfd706680d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbb61538-1d5b-4e54-864c-314aa6a4ac87"/> </reportElement> <textFieldExpression><![CDATA[$F{invoiceNo}]]></textFieldExpression> </textField> <textField> <reportElement x="185" y="0" width="185" height="30" uuid="d83517c6-4d51-490a-94e3-ae78e4e60693"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="5bcddd82-bece-48bf-8d64-98092796d145"/> </reportElement> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> <textField> <reportElement x="370" y="0" width="185" height="30" uuid="6c8b1a93-cc44-4a2d-b47b-ed860e9575c4"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="645fb340-d87c-44ca-bfab-31d97554b215"/> </reportElement> <textFieldExpression><![CDATA[$F{value}]]></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>[/code]Some simple explanation regarding the JSONQL queries: 1. The query string "..items.*" simple traslates to: pick all the children(.*) of "items", wherever(..) the "items" key resides in the JSON tree. 2. The "^^.number" query traslates to: go back up twice in the JSON tree to reach the invoice item, then select the number key. An equivalent syntax for this query is: "^{2}.number" 3. More on the JSONQL query language here: http://jasperreports.sourceforge.net/sample.reference/jsonqldatasource/index.html#jsonql If JSONQL is not an option for you, checkout the jsondatasource sample code from our repository here: https://github.com/TIBCOSoftware/jasperreports/tree/master/jasperreports/demo/samples/jsondatasource
  5. It depends on how complex are your JSON data and the desired output. Could you detail more on that?
  6. Although not obvious, you need a "[0]" expression for your field in the subreport, like so: <field name="multi_value" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> <fieldDescription><![CDATA[multi_value]]></fieldDescription></field>[/code]If you want to access the array values in a more concise way without using subreports, you could iterate directly over the multi_values items then travel up the JSON tree for the other values: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b --><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="76779812-15b1-4e44-ad29-10e660c7e020"> <queryString language="jsonql"> <![CDATA[..multi_values.*]]> </queryString> <field name="value" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> <fieldDescription><![CDATA[Value]]></fieldDescription> </field> <field name="itemName" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.item_name"/> <fieldDescription><![CDATA[item name]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <columnHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement x="277" y="0" width="278" height="30" uuid="fd4f82c2-abbe-4ef8-8eb8-91afd9db6c46"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0499f481-103c-4059-a47e-03973f8e0a26"/> </reportElement> <text><![CDATA[Value]]></text> </staticText> <staticText> <reportElement x="0" y="0" width="277" height="30" uuid="3a9080a0-6b05-4ec9-a0d3-fec572c39796"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="95758653-15a1-4f2f-818e-073c28049db5"/> </reportElement> <text><![CDATA[item Name]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <textField> <reportElement x="277" y="0" width="278" height="30" uuid="5241ef9c-fea3-499f-bf4a-58434d8872e2"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0499f481-103c-4059-a47e-03973f8e0a26"/> </reportElement> <textFieldExpression><![CDATA[$F{value}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="0" width="277" height="30" uuid="baaf49be-1cd2-42f0-b8fb-948146979e58"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="95758653-15a1-4f2f-818e-073c28049db5"/> </reportElement> <textFieldExpression><![CDATA[$F{itemName}]]></textFieldExpression> </textField> </band> </detail></jasperReport>[/code]
  7. It looks like you have an encoding issue. If your data comes from a JSON file you need to make sure it is UTF-8 encoded.
  8. You need to use the "Page X of Y" palette component which is a composite element made out of two textFields with different evaluationTime setting for each. After you drop the component and inspect the JRXML you should see something like this in the Source tab: <textField> <reportElement x="354" y="14" width="100" height="30" uuid="5fa7916e-f99d-4bdf-b28f-fc08c8ed99f8"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression></textField><textField evaluationTime="Report"> <reportElement x="454" y="14" width="100" height="30" uuid="84dcff42-e5e3-4309-877c-020f91153bdc"/> <textElement textAlignment="Left"/> <textFieldExpression><![CDATA[" of " + $V{PAGE_NUMBER}]]></textFieldExpression></textField>[/code]EDIT: Regarding the repeating footer issue, this happens because the crosstab ends-up in a Summary band for which the footer band does not repeat when it overflows. To overcome this issue, once you have added the Page Footer band with the pagination textField(s) you need to set the report property: Summary With Page Header And Footer to true, in the Report Properties tab, in JasperSoft Studio, or manually edit the JRXML by adding: isSummaryWithPageHeaderAndFooter="true" to the top-level jasperReports tag: <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" ... isSummaryWithPageHeaderAndFooter="true" ... uuid="31ce6514-6e4a-4667-a352-02d0b047a48b">[/code]
  9. I have an old stackoverflow post explaining how to push XML/JSON data to a report deployed in JasperReports Server and some basic ways to test it: https://stackoverflow.com/a/37441567/5882963 That could be a starting point.
  10. Your subreport's dataSource expression needs to look like this: <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("cad_mod_inv")]]></dataSourceExpression>[/code]because you are already iterating items under the cad_mod key(you specified that in the the main report's query string).
  11. You are calling a method that does not exist: SubDataSource(String). However, the subDataSource(String) method exists(method names start with lowercase letters in Java). Use that instead.
  12. Maybe this answer here helps: https://community.jaspersoft.com/questions/1107291/traversing-json-output-rest-api-datasource
  13. Maybe this solution here helps: https://community.jaspersoft.com/questions/1118591/view-json-data-adapter-data-table
  14. For a basic table-like preview you can just add the fields in the main dataset and get something like: <?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="Users" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="61928541-d006-4374-9164-985c6c4116c9"> <queryString language="JSON"> <![CDATA[]]> </queryString> <field name="id" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="id"/> <fieldDescription><![CDATA[id]]></fieldDescription> </field> <field name="name" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="name"/> <fieldDescription><![CDATA[name]]></fieldDescription> </field> <field name="ord" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="ord"/> <fieldDescription><![CDATA[ord]]></fieldDescription> </field> <field name="visible" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="visible"/> <fieldDescription><![CDATA[visible]]></fieldDescription> </field> <title> <band height="51"> <staticText> <reportElement x="180" y="0" width="200" height="30" uuid="90b36b64-6fb2-4076-ac5c-f9799d0eace1"/> <textElement textAlignment="Center" verticalAlignment="Justified"> <font size="14"/> </textElement> <text><![CDATA[basic Preview]]></text> </staticText> </band> </title> <columnHeader> <band height="30"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="120" height="30" backcolor="#C2F9FC" uuid="a4247667-3f3f-4154-9dbd-53317fa1b94d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bd83a66d-284a-45b0-9211-3537ee4a9bb1"/> </reportElement> <text><![CDATA[id]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="120" y="0" width="120" height="30" backcolor="#C2F9FC" uuid="8f508ddb-4f4d-4b31-a39e-2899bc041aac"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="db194b8e-d7c3-4d1d-b052-8591596fdf14"/> </reportElement> <text><![CDATA[name]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="240" y="0" width="120" height="30" backcolor="#C2F9FC" uuid="8eef734b-a06f-4594-8d5f-9ff3a096d3ce"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6fe6e49e-7615-42bd-a8e4-62509007105f"/> </reportElement> <text><![CDATA[ord]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="360" y="0" width="120" height="30" backcolor="#C2F9FC" uuid="a0161638-78ff-4793-9d0e-2fe3c870f95b"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="07c87beb-832f-4b31-b437-db5ec6916e99"/> </reportElement> <text><![CDATA[visible]]></text> </staticText> </band> </columnHeader> <detail> <band height="30"> <textField> <reportElement x="0" y="0" width="120" height="30" uuid="c2d72779-0e0a-429b-aa62-6316d17bc132"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bd83a66d-284a-45b0-9211-3537ee4a9bb1"/> </reportElement> <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> </textField> <textField> <reportElement x="120" y="0" width="120" height="30" uuid="a1847755-6bd5-476f-bfc9-699592d9a7bd"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="db194b8e-d7c3-4d1d-b052-8591596fdf14"/> </reportElement> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> <textField> <reportElement x="240" y="0" width="120" height="30" uuid="2c4acd56-bf85-4479-aa91-0095636faeae"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6fe6e49e-7615-42bd-a8e4-62509007105f"/> </reportElement> <textFieldExpression><![CDATA[$F{ord}]]></textFieldExpression> </textField> <textField> <reportElement x="360" y="0" width="120" height="30" uuid="e61e5e61-d93d-479f-aa8c-c166fe3e3df3"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="07c87beb-832f-4b31-b437-db5ec6916e99"/> </reportElement> <textFieldExpression><![CDATA[$F{visible}]]></textFieldExpression> </textField> </band> </detail></jasperReport>[/code]If you need to display the data in a subDataset-based element there are some additional steps you need to perform in your case. For a table-based report you could: 1. Switch the query language to JSONQL to be able to travel up the JSON tree 2. Set the query to select only the first element 3. Create a subDataset with the desired fields 4. Add a custom dataSourceExpression to your table's datasetRun that moves up the JSON tree and selects the entire array You should be getting something like: <?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="Users" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="61928541-d006-4374-9164-985c6c4116c9"> <subDataset name="TableDataset" uuid="773ceda1-586c-40f8-82fd-933dad400bc5"> <field name="id" class="java.lang.Integer"> <property name="net.sf.jasperreports.jsonql.field.expression" value="id"/> <fieldDescription><![CDATA[id]]></fieldDescription> </field> <field name="name" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="name"/> <fieldDescription><![CDATA[name]]></fieldDescription> </field> <field name="ord" class="java.lang.Integer"> <property name="net.sf.jasperreports.jsonql.field.expression" value="ord"/> <fieldDescription><![CDATA[ord]]></fieldDescription> </field> <field name="visible" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="visible"/> <fieldDescription><![CDATA[visible]]></fieldDescription> </field> </subDataset> <queryString language="JSONQL"> <![CDATA[[0]]]> </queryString> <title> <band height="51"> <staticText> <reportElement x="180" y="0" width="200" height="30" uuid="90b36b64-6fb2-4076-ac5c-f9799d0eace1"/> <textElement textAlignment="Center" verticalAlignment="Justified"> <font size="14"/> </textElement> <text><![CDATA[Table Preview]]></text> </staticText> </band> </title> <columnHeader> <band height="20"/> </columnHeader> <detail> <band height="60"> <componentElement> <reportElement x="0" y="0" width="430" height="60" uuid="d7f20fb3-d6c3-42bd-91b3-e929f6af9e87"/> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="TableDataset" uuid="6597a01b-64d4-4286-ae68-f70f31295f2f"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("^")]]></dataSourceExpression> </datasetRun> <jr:column width="110" uuid="9805d0a9-fcb9-4ea0-b29e-2fb73ac61cf7"> <jr:columnHeader height="30"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="110" height="30" backcolor="#C2F9FC" uuid="60409ca5-0195-41b4-803c-584434e71927"/> <text><![CDATA[id]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="110" height="30" uuid="4b178ab7-2a84-4f11-a309-2f830a20d526"/> <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="100" uuid="4c82b871-dacb-4251-9036-952777d48f63"> <jr:columnHeader height="30"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="100" height="30" backcolor="#C2F9FC" uuid="cb5da1fa-a943-4abe-9b33-24d418a101fc"/> <text><![CDATA[name]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="811fd3f8-1c69-4f28-82aa-ae820e222870"/> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="110" uuid="5e689a36-a2c3-4426-8949-e2a6ea16fd84"> <jr:columnHeader height="30"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="110" height="30" backcolor="#C2F9FC" uuid="7822f0f3-2532-4f5c-9986-9cd1113cbc50"/> <text><![CDATA[ord]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="110" height="30" uuid="9de8cef4-1fd6-4185-9f32-fc89f79defba"/> <textFieldExpression><![CDATA[$F{ord}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="110" uuid="cafc6c4f-32e6-4932-872a-e7c1e07cf65e"> <jr:columnHeader height="30"> <staticText> <reportElement mode="Opaque" x="0" y="0" width="110" height="30" backcolor="#C2F9FC" uuid="1cf010d7-f399-4c6b-a027-3696a1f4439b"/> <text><![CDATA[visible]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="110" height="30" uuid="140206f5-fb7d-4824-8299-6cf1a8e2b5a9"/> <textFieldExpression><![CDATA[$F{visible}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </detail></jasperReport>[/code]
  15. Please post complete sample JSON data and also mention the version of Jaspersoft Studio
  16. Your textFields displaying data are too small for showing anything. Either try: - setting 'Stretch With Overflow' in the 'Text Field' tab of the textField's properties panel - or gradually lower the font size on the textField untill you see the data - or increase the textField's height EDIT: Since I cannot test the code that you are running your report with, I can only mention some guidelines: - make sure your json file is in classpath - remove this line from your JRXML as it might attempt to load the json data from there, in case you pass a null InputStream: <property name="net.sf.jasperreports.json.source" value="data/example_fincalc_data.json"/> - or you could just set this parameter in your parameters map: params.put(JsonQueryExecuterFactory.JSON_SOURCE, "classpath/to/json/file"); - you don't need to construct a JsonDatasource instance for filling the report as it will be constructed automatically based on the parameters you've just passed In essence your code should look simpler, like so: params.put(JsonQueryExecuterFactory.JSON_DATE_PATTERN, "yyyy-MM-dd");params.put(JsonQueryExecuterFactory.JSON_NUMBER_PATTERN, "#,##0.##");params.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.US);params.put(JRParameter.REPORT_LOCALE, Locale.US); params.put(JsonQueryExecuterFactory.JSON_SOURCE, "com/ca/services/reportgencore/api/testnorthworks.json");// Load the compiled template system and output the PDF documentfinal JasperReport report = TestJasperReportUtil.loadJASPERFile("/com/ca/services/reportgencore/api/SimpleDataJust.jasper");final JasperPrint jasperPrint = JasperFillManager.fillReport(report, params);pdf = JasperExportManager.exportReportToPdf(jasperPrint);[/code]
  17. If your parameter is of type java.lang.String then you should have a properly escaped String like so: "{"operation":"list_operations"}"
  18. Try using JSONQL instead of Webservice Query. Create a JSON file Data Adapter where you specify your JSON URL and check "Use the report JSON expression when filling the report". Then in your report Dataset and Query Dialog pick the adapter and chose "jsonql" as language. Then use this expression to query for fields: objects["Server::.*"]
  19. I understand that you want to remove the "::key" part, but is the output of the report that you want to achieve?
  20. What is your desired output? Are you tied to using the Webservice Datasource?
×
×
  • Create New...