Jump to content
Changes to the Jaspersoft community edition download ×

Problems with images-JRTableModelDataSource


Mange

Recommended Posts

I have a problem getting an image per row in detail.

 

I have created my own tableModelwhere I define the columns as String, Object

 

I then use setValueAT to insert 2 buffered images.

 

I get a ClassCastException when I try to fill the report.

 

jasperPrint = JasperFillManager.fillReport(jasperReport, param, new JRTableModelDataSource(table.getModel()));

 

TIA

 

PS. If I change the report to java.awt.Image the report doesn't compile.

 

PPS. I tried to just insert a direct path in my table instead of BI and it worked. Howerver, I will create charts as BI per row in my table.

 

--- java ---

Code:

static class MyTableModel extends AbstractTableModel {
private String[] columnNames = {"Field",
"image2"};
private Object[][] data = {
{"First Line", new Object()},
{"Second Line", new Object()}
};
public void setValueAt(Object value, int row, int col) {
data[row][col] = value;
fireTableCellUpdated(row, col);
}
}


--- jrxml ---

Code:
[code]
<parameter name="image1" isForPrompting="true" class="java.lang.Object"/>


<image scaleImage="RetainShape"
evaluationTime="Now"
hyperlinkType="None"
hyperlinkTarget="Self" >
<reportElement x="4" y="33" width="376" height="162" key="image-1"/>
<box topBorder="None" topBorderColor="#000000"
leftBorder="None" leftBorderColor="#000000"
rightBorder="None" rightBorderColor="#000000"
bottomBorder="None" bottomBorderColor="#000000"/>
<graphicElement stretchType="NoStretch" pen="4Point" fill="Solid" />
<imageExpression class="java.lang.String"><![CDATA[$F{image2}]]></imageExpression>
</image>

--- error ---

Code:
[code]
java.lang.ClassCastException

at Simple_Report_1158667614968_767996.evaluate(Simple_Report_1158667614968_767996.java:167)

at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507)

at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:807)

at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:447)class java.awt.image.BufferedImage



at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:430)

at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277)

at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)

at jaspertest1.JasperReportsIntro.main(JasperReportsIntro.java:46)


NESTED BY :

java.lang.ClassCastException

at Simple_Report_1158667614968_767996.evaluate(Simple_Report_1158667614968_767996.java:167)

at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507)

at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:807)

at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:447)

at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:430)

at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277)

at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)

at jaspertest1.JasperReportsIntro.main(JasperReportsIntro.java:46)


NESTED BY :

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{image2}

at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:183)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507)

at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:807)

at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:447)

at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:430)

at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277)

at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)

at jaspertest1.JasperReportsIntro.main(JasperReportsIntro.java:46)

Caused by: java.lang.ClassCastException

at Simple_Report_1158667614968_767996.evaluate(Simple_Report_1158667614968_767996.java:167)

at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172)

... 16 more

Post edited by: mbjorkman, at: 2006/09/19 12:50

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...