Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jasper reports - Jasperreports - how to get JSON to populate a subreport

I am trying to get a table to populate with the same data in my main report using Jasper/iReport. How can I get the Json to carry over?

In Edit table datasource I've tried:

((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE})

new ((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE})

$P{REPORT_DATA_SOURCE}

$P{REPORT_CONNECTION}

All of which compile, but none of which actually generate a table. Any ideas? There is no method like cloneDataSource() for JSON so what is the alternative?

My ultimate goal is simple: to pass in JSON data and use it to generate a chart, and then have a table displaying the same information. I have been working for days on this, Jasper is giving me a hard time. Please help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was struggling with a similar problem when using sub reports. It seems that the JSON datasource gets consumed by the main report so you need to invoke subDataSource() to get a fresh datasource for your sub reports and maybe for tables, too - haven't tested that yet though...

Data Source Expression: ((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...