Jump to content

allan.meek

Members
  • Posts

    6
  • Joined

  • Last visited

 Content Type 

Forum

Downloads

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Events

Profiles

Posts posted by allan.meek

  1. Good day,

    We have enabled virtualization when generating reports:

      JRSwapFile swapFile = new JRSwapFile(configurationService.getReportResourcePath(), VIRT_BLOCK_SIZE, VIRT_PAGE_COUNT);
      JRSwapFileVirtualizer virtualizer = new JRSwapFileVirtualizer(VIRT_PAGE_COUNT, swapFile);
      virtualizer.setReadOnly(false);

      param.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
      jasperPrint = JasperFillManager.fillReport(jasperReport, param);

    However, when we try to generate a report longer than VIRT_PAGE_COUNT, we get the following error:

    net.sf.jasperreports.engine.util.SwapFileVirtualizerStore store
    SEVERE: Error virtualizing object 145329976_33558975_1_-1314094481 to JRSwapFile /reportResources/resources/swap_194903130_1598288065087
    java.io.NotSerializableException: net.sf.jasperreports.compilers.JavaScriptFunctionsObject
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
      {...}
      at net.sf.jasperreports.engine.virtualization.VirtualizationOutput.writeJRObject(VirtualizationOutput.java:88)
      {...}
      at net.sf.jasperreports.engine.util.SwapFileVirtualizerStore.store(SwapFileVirtualizerStore.java:97)
    {...}
    net.sf.jasperreports.engine.JRRuntimeException: Error virtualizing object.
      at net.sf.jasperreports.engine.util.SwapFileVirtualizerStore.store(SwapFileVirtualizerStore.java:113)
      {...}
      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:966)
      {...}
    Caused by: java.io.NotSerializableException: net.sf.jasperreports.compilers.JavaScriptFunctionsObject
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
      {...}
      at net.sf.jasperreports.engine.virtualization.VirtualizationOutput.writeJRObject(VirtualizationOutput.java:88)
      {...}

    I've omitted a number of lines from the stack trace above for brevity, but I can make the whole thing available if necessary.

    This is due to the report using JavaScript functions in variables like this:

      <variable name="ct_devices_obj" class="java.lang.Object" resetType="Group" resetGroup="Target">
        <variableExpression><![CDATA[true? function () {
          var acc = $V{ct_devices_obj};
          if (acc == null) {
            acc = {
              array:[]
            };
          }
          return acc;
        }():null]]></variableExpression>
      </variable>

    Is this incompatibility a known issue? Is there a way to make JavaScript work with virtualization, or do we need to switch the report's language back to Java, and figure out how to rewrite our variable expressions in that language?

    Thanks!

  2. We have a requirement to include multi-page documents in our reports. Since there is no document-specific control for embedding documents (Word, RTF, etc.), I've looked into converting these documents into images and displaying them with the image control.

    However, my experiments in Studio have shown that the image control cannot be stretched over multiple pages - even very large images are scaled down to the size of one page. Is there a way to do this, or should I just split a document into multiple images and show one per page?

  3. I'm trying to display the contents of an array ("multi_values" in the JSON sample below) in a sub-report, but I'm missing something. The sub-report does display the correct number of Detail entries (i.e., 2 for item_name 'a' and 3 for item_name 'b'), so I know it's getting the array. However, despite numerous attempts, the subreport's textfield only ever displays "null".

    I have a couple of ideas where things could be going wrong, but I've been unable to find any documentation or questions relating to such an array in JSON data:
    * The multi_values field in the main report should have a different class (I've tried multiple other classes but nothing works)
    * The multi_value field in the sub-report needs a different field.expression value (again, I've tried multiple things and just left "multi_value" here as a placeholder)
    * The queryString in the sub-report needs to be something else

    Any input would be greatly appreciated.

    Here's the heavily reduced JSON:

    {    "items": [        {            "item_name": "a",            "multi_values": ["value1", "value2"]        },        {            "item_name": "b",            "multi_values": ["value3", "value4", "value5"]        }    ]}

    The main report:

    <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="MultiValueExample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="988c6c04-ee0c-4e28-8121-de3584ad30b4">    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="MultiValueExample.xml"/>    <queryString language="jsonql">        <![CDATA[items]]>    </queryString>    <field name="item_name" class="java.lang.String">        <property name="net.sf.jasperreports.jsonql.field.expression" value="item_name"/>        <fieldDescription><![CDATA[item_name]]></fieldDescription>    </field>    <field name="multi_values0" class="java.lang.String">        <property name="net.sf.jasperreports.jsonql.field.expression" value="multi_values[0]"/>        <fieldDescription><![CDATA[multi_values0]]></fieldDescription>    </field>    <field name="multi_values" class="java.lang.String">        <property name="net.sf.jasperreports.jsonql.field.expression" value="multi_values"/>        <fieldDescription><![CDATA[multi_values]]></fieldDescription>    </field>    <detail>        <band height="59" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="100" height="16" uuid="90cf147e-e35f-4a6a-8de2-87287688a229">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <textFieldExpression><![CDATA[$F{item_name}]]></textFieldExpression>            </textField>            <textField>                <reportElement x="110" y="0" width="100" height="16" uuid="90cf147e-e35f-4a6a-8de2-87287688a229">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <textFieldExpression><![CDATA[$F{multi_values0}]]></textFieldExpression>            </textField>            <subreport>                <reportElement x="0" y="18" width="480" height="40" uuid="cf743a67-8fcb-407d-9762-848428411202"/>                <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource("multi_values")]]></dataSourceExpression>                <subreportExpression><![CDATA["MultiValueExampleSub.jasper"]]></subreportExpression>            </subreport>        </band>    </detail></jasperReport>

    And the sub-report:

    <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="MultiValueExampleSub" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6c426da9-4d08-46e0-a3fa-da99beedbeed">    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>    <queryString language="jsonql">        <![CDATA[]]>    </queryString>    <field name="multi_value" class="java.lang.String">        <property name="net.sf.jasperreports.jsonql.field.expression" value="multi_value"/>        <fieldDescription><![CDATA[multi_value]]></fieldDescription>    </field>    <detail>        <band height="21">            <textField>                <reportElement x="0" y="0" width="280" height="16" uuid="c6e03595-dba0-49ea-bc8f-224fd23a45c9">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </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>                <textFieldExpression><![CDATA[$F{multi_value}]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>

×
×
  • Create New...