Cannot marshal an image object into JasperReports

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Cannot marshal an image object into JasperReports

PGandy
When I try to marshal an image inside a title object, the resultant object is unusable.  To verify the direction I wanted to go, I created the following in iReports which added an image to the title of my report:
---------------------------------------------------------------------------------------------------
<image  evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
        <reportElement
                x="593"
                y="9"
                width="79"
                height="38"
                key="image-1"/>
        <box></box>
        <graphicElement stretchType="NoStretch"/>
        <imageExpression class="java.lang.String">
<![CDATA["Resources\\CompanyLogo.png"]]>
</imageExpression>
</image>
---------------------------------------------------------------------------------------------------

Following the format that has worked for similar objects, I added this VisualWorks code to a method I use to create the report's title:
---------------------------------------------------------------------------------------------------
        (aTitle band choiceValue)
                add: (Core.Association key: #image value: OrderedCollection new);
                yourself.
        anImage := JASPER.Image new.
        anImage
                evaluationTime: 'Now';
                hyperlinkType: 'None';
                hyperlinkTarget: 'Self'.
        anImage reportElement: JASPER.ReportElement new.
        anImage reportElement x: '593';
                                y: '9';
                                width: 79;
                                height: '38';
                                key: 'image-1'.
        anImage box: (JASPER.Box new).
        anImage graphicElement: (JASPER.GraphicElement new stretchType: 'NoStretch').
        anImage imageExpression: (JASPER.ImageExpression new).
        anImage imageExpression javaClass: 'java.lang.String'.
        anImage imageExpression value: '![CDATA["Resources\\CompanyLogo.png"]]'.
        aTitle band choiceValue image add: anImage.
---------------------------------------------------------------------------------------------------

I then debug the code that marshals the report.  After executing the code below, jasperReportElement is an XML.Element.  If I inspect its elements I see the error message, "[Error printing the object: This message is not appropriate for this object]"
---------------------------------------------------------------------------------------------------
jasperReportElement := manager marshal: self asJasperReport
                                atNamespace: 'urn:adventact-com:JASPER'.
---------------------------------------------------------------------------------------------------
jasperReportElement is unusable at this point and I get a walkback in the code trying to access it.

If anyone has succeeded in marshaling an image object, I would love to hear from them.

Thanks,
Paul