rexbutler Posted July 7, 2011 Share Posted July 7, 2011 Quick question: in can one insert an image into an iReport whose filename is determined dynamically via a database value just like one can display a dynamic database string?Thanks,Rex Link to comment Share on other sites More sharing options...
jmurray Posted July 11, 2011 Share Posted July 11, 2011 If the pics are stored locally on the report server then you can reference them directly, but if they're on (say) a remote web server you'll need to pass the pic url to an external image rendering tool (for example cricket grapher can render network utilisation graphs on the fly given the correct URI, and the png output files can be embedded in the report). Link to comment Share on other sites More sharing options...
jmurray Posted July 12, 2011 Share Posted July 12, 2011 The attached pdf is a sample that contains dynamically generated cricket graphs.Page 1 is just a title page. Page 2 contains three images that are dynamically created by an external rendering tool. Page 3 contains 4 subreports that generate jasperreport graphs from data for specific timeframes.The following query from the main report provides base textual data for the left hand side of page 2 and the URI strings that are used for the weekly, monthly and yearly cricket graphs on the right hand side of page 2. <queryString><![CDATA[select DISTINCT a.*, b.tail_fqhostname , 'http://public.nms.det.nsw.edu.au/weathermap/proxy.php?' || 'url=http://cricket.nms.det.nsw.edu.au/?type=png;target=' || substr(rrdpath,14,length(rrdpath)-17) || ';inst=0;dslist=ifHCInOctets%2CifHCOutOctets;range=604800;rand=763' as weekly , 'http://public.nms.det.nsw.edu.au/weathermap/proxy.php?' || 'url=http://cricket.nms.det.nsw.edu.au/?type=png;target=' || substr(rrdpath,14,length(rrdpath)-17) || ';inst=0;dslist=ifHCInOctets%2CifHCOutOctets;range=2592000;rand=763' as monthly , 'http://public.nms.det.nsw.edu.au/weathermap/proxy.php?' || 'url=http://cricket.nms.det.nsw.edu.au/?type=png;target=' || substr(rrdpath,14,length(rrdpath)-17) || ';inst=0;dslist=ifHCInOctets%2CifHCOutOctets;range=31536000;rand=763' as yearly from planned_bw a, rrd_paths_path b, planned_bw_consumption c where a.HOSTNAME || '.net.det.nsw.edu.au'= c.hostname and A.HOSTNAME || '.net.det.nsw.edu.au'= b.tail_fqhostname and a.hostname='cabr01' and ( c.consumption_key = $P!{consumption_key1} or c.consumption_key = $P!{consumption_key2} or c.consumption_key = $P!{consumption_key3} or c.consumption_key = $P!{consumption_key4} ) order by A.REGION, A.SITE_NAME]]>[/code]The URI strings contain a URL for the wrapper cgi script, a rendering URL for the cricket grapher, the path to the interface to be graphed and the parameters required by the cricket grapher to render the correct counters for the right period (in this case one week):wrapper cgi: 'http://public.nms.my.hidden.web.site/weathermap/proxy.php?'render URL: 'url=http://cricket.nms.my.hidden.web.site/?type=png;target='target path: substr(rrdpath,14,length(rrdpath)-17)parameters: ';inst=0;dslist=ifHCInOctets%2CifHCOutOctets;range=604800;rand=763' as weekly[/code]The assembled URI might look something like this:http://public.nms.my.hidden.web.site/weathermap/proxy.php?url=http://cricket.nms.my.hidden.web.site/?type=png;target=/routers/offices/swsy/cabr01/gigabitethernet0_0;inst=0;dslist=ifHCInOctets%2CifHCOutOctets;range=604800;rand=763 The URI is then used in an image element like this:<image hyperlinkType="Reference"> <reportElement key="image-1" x="395" y="10" width="385" height="160"/> <imageExpression class="java.lang.String"><![CDATA[$F{WEEKLY}]]></imageExpression> <hyperlinkReferenceExpression><![CDATA[$F{WEEKLY}]]></hyperlinkReferenceExpression></image>[/code]Hope this helps if you were considering using an external rendering tool. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now