Jump to content

Differences between studio and library


bamabi45320

Recommended Posts

Hi,

First, I have a report in Jaspersoft Studio which is fill with json data.

The JRXML :

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  --><!-- 2016-01-20T15:40:26 --><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="Appreciation" pageWidth="595" pageHeight="842" columnWidth="555"              leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"              whenResourceMissingType="Empty"              uuid="0b6679e8-cc7a-46e7-bbaf-1da414c8fb1b">    <property name="com.jaspersoft.studio.data.defaultdataadapter"              value="NEW_DATAADAPTER.xml"/>    <style name="Table 1_TH" mode="Opaque" backcolor="#F0F8FF">        <box>            <pen lineWidth="0.5" lineColor="#000000"/>            <topPen lineWidth="0.5" lineColor="#000000"/>            <leftPen lineWidth="0.5" lineColor="#000000"/>            <rightPen lineWidth="0.5" lineColor="#000000"/>        </box>    </style>    <style name="Table 1_CH" mode="Opaque" backcolor="#BFE1FF">        <box>            <pen lineWidth="0.5" lineColor="#000000"/>            <topPen lineWidth="0.5" lineColor="#000000"/>            <leftPen lineWidth="0.5" lineColor="#000000"/>            <bottomPen lineWidth="0.5" lineColor="#000000"/>            <rightPen lineWidth="0.5" lineColor="#000000"/>        </box>    </style>    <style name="Table 1_TD" mode="Opaque" backcolor="#FFFFFF">        <box>            <pen lineWidth="0.5" lineColor="#000000"/>            <topPen lineWidth="0.5" lineColor="#000000"/>            <leftPen lineWidth="0.5" lineColor="#000000"/>            <bottomPen lineWidth="0.5" lineColor="#000000"/>            <rightPen lineWidth="0.5" lineColor="#000000"/>        </box>    </style>    <subDataset name="Dataset1" uuid="ce13b324-3856-4305-82ef-b9f536cfe078">        <property name="com.jaspersoft.studio.data.defaultdataadapter"                  value="NEW_DATAADAPTER.xml"/>        <queryString language="json">            <![CDATA
  • ]> </queryString> <field name="crpPromo" class="java.lang.String"> <fieldDescription> <![CDATA[crpPromo]]> </fieldDescription> </field> <field name="datePromo" class="java.lang.String"> <fieldDescription> <![CDATA[datePromo]]> </fieldDescription> </field> <field name="modePromo" class="java.lang.String"> <fieldDescription> <![CDATA[modePromo]]> </fieldDescription> </field> <group name="crpPromo"> <groupExpression> <![CDATA[$F{crpPromo}]]> </groupExpression> </group> <group name="datePromo"> <groupExpression> <![CDATA[$F{datePromo}]]> </groupExpression> </group> <group name="modePromo"> <groupExpression> <![CDATA[$F{modePromo}]]> </groupExpression> </group> </subDataset> <queryString language="JSON"> <![CDATA
    • ]> </queryString> <field name="nom1" class="java.lang.String"> <fieldDescription> <![CDATA[nom1]]> </fieldDescription> </field> <field name="prenom1" class="java.lang.String"> <fieldDescription> <![CDATA[prenom1]]> </fieldDescription> </field> <field name="dateNaissance1" class="java.lang.String"> <fieldDescription> <![CDATA[dateNaissance1]]> </fieldDescription> </field> <field name="matricule" class="java.lang.String"> <fieldDescription> <![CDATA[matricule]]> </fieldDescription> </field> <field name="corps" class="java.lang.String"> <fieldDescription> <![CDATA[corps]]> </fieldDescription> </field> <field name="grade" class="java.lang.String"> <fieldDescription> <![CDATA[grade]]> </fieldDescription> </field> <field name="ech" class="java.lang.String"> <fieldDescription> <![CDATA[ech]]> </fieldDescription> </field> <group name="Groupe1" isStartNewPage="true" isResetPageNumber="true" isReprintHeaderOnEachPage="true"> <groupExpression> <![CDATA[$F{matricule}]]> </groupExpression> <groupHeader> <band height="250"> <staticText> <reportElement x="0" y="15" width="200" height="35" forecolor="#F54927" uuid="7cab88d7-62e9-4bd0-831a-2808cd6411eb"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font size="15"/> </textElement> <text> <![CDATA[Dossier d'appréciation 2013]]> </text> </staticText> <frame> <reportElement x="8" y="70" width="539" height="180" uuid="a5e959ea-6f13-4781-b990-a62e8fb04ae9"> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> </reportElement> <box> <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> </box> <textField> <reportElement x="272" y="160" width="264" height="18" uuid="17594476-7ec8-4ce4-a959-b896d86a6aa7"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{ech}]]> </textFieldExpression> </textField> <textField> <reportElement x="272" y="142" width="265" height="18" uuid="eaa5e8d4-c988-42f7-9ab0-e364c87cccab"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{grade}]]> </textFieldExpression> </textField> <textField> <reportElement x="272" y="124" width="265" height="18" uuid="f8fd76fc-a4b6-448d-a186-aa67b71b003e"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{corps}]]> </textFieldExpression> </textField> <staticText> <reportElement x="2" y="124" width="270" height="18" forecolor="#2F63DE" uuid="3e9c827e-6d19-4964-a6e7-43d50b2268c4"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <text> <![CDATA[Corps :]]> </text> </staticText> <staticText> <reportElement x="2" y="142" width="270" height="18" forecolor="#2F63DE" uuid="096c7886-88cb-4bc6-b246-0b79d563de28"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <text> <![CDATA[Grade :]]> </text> </staticText> <staticText> <reportElement x="2" y="160" width="270" height="18" forecolor="#2F63DE" uuid="718346be-aad3-4769-b233-37c97512fa75"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <text> <![CDATA[Echelon :]]> </text> </staticText> <staticText> <reportElement mode="Opaque" x="2" y="3" width="535" height="20" forecolor="#F54927" backcolor="#C5C9C9" uuid="7ca69dd5-881f-4d12-a233-a4e025aeac7f"> <property name="com.jaspersoft.studio.unit.x" value="pixel"/> </reportElement> <box leftPadding="5"> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <text> <![CDATA[Proposé à l'avancement]]> </text> </staticText> <staticText> <reportElement x="2" y="23" width="270" height="18" forecolor="#2F63DE" uuid="ffe0ce07-a04d-4799-bbab-b449553fc263"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12" isBold="true"/> </textElement> <text> <![CDATA[Nom d'usage :]]> </text> </staticText> <staticText> <reportElement x="2" y="41" width="270" height="18" forecolor="#2F63DE" uuid="e5976d5a-6f10-42b6-9560-7ec11ac3fedc"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12" isBold="true"/> </textElement> <text> <![CDATA[Prénom :]]> </text> </staticText> <staticText> <reportElement x="2" y="59" width="270" height="18" forecolor="#2F63DE" uuid="8aa2b1ec-372d-447e-9fd6-4094dc438483"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <text> <![CDATA[Nom de famille :]]> </text> </staticText> <textField> <reportElement x="272" y="59" width="265" height="18" uuid="20e4e77c-d294-4017-aa03-368288ab7de3"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{nom1}]]> </textFieldExpression> </textField> <textField> <reportElement x="272" y="41" width="265" height="18" uuid="22a5d3b0-1ad2-4ec1-8c38-81a2edd8a545"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{prenom1}]]> </textFieldExpression> </textField> <textField> <reportElement x="272" y="23" width="265" height="18" uuid="da483180-115d-4302-bb84-4b85c4930737"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{nom1}]]> </textFieldExpression> </textField> <staticText> <reportElement x="2" y="77" width="270" height="18" forecolor="#2F63DE" uuid="449f9adc-1851-4637-91f0-46f918ebabab"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <text> <![CDATA[Date de naissance :]]> </text> </staticText> <textField> <reportElement x="272" y="77" width="265" height="18" uuid="79407234-3b50-4329-adfd-96ada5cf338c"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{dateNaissance1}]]> </textFieldExpression> </textField> <textField> <reportElement x="272" y="95" width="264" height="18" uuid="ee1d1c8d-ebdb-467e-a81a-2d304d59cb68"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{matricule}]]> </textFieldExpression> </textField> <staticText> <reportElement x="2" y="95" width="270" height="18" forecolor="#2F63DE" uuid="882b1bb7-c46c-455a-a930-cee75b7a71d5"/> <box topPadding="1" leftPadding="5"> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <text> <![CDATA[Matricule]]> </text> </staticText> <line> <reportElement x="10" y="118" width="520" height="1" forecolor="#2F63DE" uuid="01e8becb-0219-4275-a209-62b26c067f55"> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> <property name="com.jaspersoft.studio.unit.x" value="pixel"/> </reportElement> </line> </frame> </band> </groupHeader> </group> <background> <band splitType="Stretch"/> </background> <detail> <band height="18" splitType="Stretch"> <componentElement> <reportElement x="10" y="0" width="537" height="18" uuid="65053ddc-606f-4bbf-a62c-0a20bef5641f"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> </reportElement> <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="Dataset1" uuid="6b686496-6540-4aa5-b078-2ab3c570c6af"> <dataSourceExpression> <![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("")]]> </dataSourceExpression> </datasetRun> <jr:column width="178" uuid="c72b858b-8b01-4812-b10f-b8d97404b788"> <jr:detailCell style="Table 1_TD" height="18"> <textField> <reportElement x="0" y="0" width="178" height="18" uuid="7ed85ae4-2da1-415d-b34a-72e91fa1a301"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{crpPromo}]]> </textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="178" uuid="fa54b4c8-59f1-4e7c-9b66-1517ae5a4ced"> <jr:detailCell style="Table 1_TD" height="18"> <textField> <reportElement x="0" y="0" width="178" height="18" uuid="f8a894c5-930f-493b-8587-15640fb36934"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{datePromo}]]> </textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="178" uuid="be2cb39b-9719-4678-bdc3-26b3c198835a"> <jr:detailCell style="Table 1_TD" height="18"> <textField> <reportElement x="0" y="0" width="178" height="18" uuid="3a1f0d06-c458-49a9-b186-301201301286"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression> <![CDATA[$F{modePromo}]]> </textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </detail></jasperReport>[/code]

The JSON datas :

{
  "list": [
    {
      "matricule": 123456789,
      "dateNaissance1": 315529200000,
      "modePromo": "Concour ext.",
      "ech": 4,
      "prenom1": "PrenomAgent",
      "corps": "Ingénieur de recherche",
      "nom1": "NomAgent",
      "grade": "1e classe",
      "datePromo": 1451602800000,
      "crpPromo": "IR1",
    },
    {
      "matricule": 251413,
      "dateNaissance1": 631148400000,
      "modePromo": "Concour int.",
      "ech": 2,
      "prenom1": "Jean",
      "corps": "Techniciens de maintenance",
      "nom1": "Torres",
      "grade": "2e classe",
      "datePromo": 1451602800000,
      "crpPromo": "TM2",
    }
  ]
}
 
It works perfectly on studio but when a try to use thoses files in my java application, i have just one page and all the fields are null.
 
JAVA :
public JasperPrint preparePrinter(final InputStream pDatas, final InputStream pReport) {
        JasperDesign jasperDesign = null;
        JasperReport jasperReport = null;
        JasperPrint jasperPrint = null;
        try {
            jasperDesign = JRXmlLoader.load(pReport);
            jasperReport = JasperCompileManager.compileReport(jasperDesign);
            final JsonDataSource app = new JsonDataSource(pDatas);
            
            // La map peut être utilisée pour passer des paramètres au rapport
            jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<String, Object>(), app);
        } catch (final JRException e) {
            _logger.debug("Erreur lors de la génération du rapport" + e.getLocalizedMessage());
        }
        return jasperPrint;
    }

I don't know where is the mistake, or if I need specifics .jar to make it works ...

Thanks for te response, regards

Alban

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...