ryanyu Report post Posted December 23, 2009 Hi, I am trying to implement the server side export function, but the following exceptions are thrown when compiling the code. What's wrong are they ? Error(50,794): method getServletContext() not found in class _fusion._exporthandler._resources._FCExporter__IMG Error(47,518): method getServletContext() not found in class _fusion._exporthandler._resources._FCExporter__PDF Remark: I am using Java 5 version of the exporter jar, provided from http://www.fusioncharts.com/forum/Topic14950-33-1.aspx Share this post Link to post Share on other sites
srividya_sharma Report post Posted December 23, 2009 Hi Can you tell me the version of Java and the server (and its version) that you are using. Please try to change, String pathToWebAppRoot = getServletContext().getRealPath("/"); to: String pathToWebAppRoot = session.getServletContext().getRealPath("/"); in FCExporter_IMG.jsp and FCExporter_PDF.jsp at the lines specified in the error log. Please tell me the version of java and tomcat or other server that you are using, so that I can update the jar for that version. Hope this helps! Srividya Share this post Link to post Share on other sites
ryanyu Report post Posted December 23, 2009 Hi Srividya, Thanks your quick response. I can compile my code successfully. For your information, my java is 1.5 version and the server is Oracle OC4J Regards, Ryan Share this post Link to post Share on other sites
srividya_sharma Report post Posted December 23, 2009 (edited) Hi Ryan, You are welcome. Thanks for the version info. I will fix it. Srividya Edited December 23, 2009 by Guest Share this post Link to post Share on other sites
ryanyu Report post Posted December 23, 2009 Hi Srividya, I also would like to ask if I need to export the chart in client side, I must right click the chart and select 'Export' , is it true ? Or is there any ways I can trigger the client side export feature, such as click the button (outside the flash chart). Share this post Link to post Share on other sites
srividya_sharma Report post Posted December 23, 2009 (edited) Hi Ryan, Yes, you CAN trigger the client-side export using Javascript. The javascript code for initiating export : <script type="text/javascript"> function ExportMyChart() { var chartObject = getChartFromId('myChart'); if( chartObject.hasRendered() ) chartObject.exportChart(); } </script> And then add a button like this: <input type="button" value="Export My Chart" onclick="ExportMyChart()" /> Please take a look at: http://www.fusioncharts.com/docs/Contents/ECJavaScript.html for further reference on initiating export from javascript. Hope this helps! Srividya Edited December 23, 2009 by Guest Share this post Link to post Share on other sites
ryanyu Report post Posted December 23, 2009 Hi Srividya, Oh..Sorry, i miss a point. Because of particular reason, my SWF files need to put on the other servers (CROSS DOMAIN), I can render normally by the method, same as you provided. However, the chart cannot be exported in client or even server side mode. Any suggestion ? Best Regards, Ryan Share this post Link to post Share on other sites
srividya_sharma Report post Posted December 24, 2009 Hi Ryan, Can you elaborate on the mechanism/ flow you are using to export? If you can pin-point the problem I would be able to suggest better. Srividya Share this post Link to post Share on other sites
ryanyu Report post Posted December 27, 2009 Hi Srividya, My application is hosted by 2 servers in different domain. One is for application JSP source code and the other is for storing the application resource files such as image, flash (SWF), js. When i implement the fusion chart in my application, I point the chart swf in the resource server, it is fully workable for rendering the chart. For exporting chart, i would like to create a button, instead of selecting "Export Chart" in right-click menu, for user to trigger the export event. However, it is not work for exporting the chart in both server and client side mode. For client side exporting, flash file FCExporter.swf is also located in resource server. For server side exporting, nothing is happen when i click the export button, which is same as your previous solution provided.. Please help. Thanks. Ryan Share this post Link to post Share on other sites
srividya_sharma Report post Posted December 29, 2009 Hi Ryan, 1. Please check if registerWithJS is set to 1. 2. Please check all the export attributes are set correctly in the xml. 3. Are you able to see the "Capturing Data" ... Dialog Box? 4. If so, then what happens after that? 5. Please attach the html ( from view source ) and xml code, for finding the source of the problem. Srividya Share this post Link to post Share on other sites
ryanyu Report post Posted December 30, 2009 Hi Srividya, Attached please find my two export source codes (for client side and server side export). Server side code can successfully export the chart image by right click the chart and select export menu item. However, it would be fail if clicking the self-created export button, it throws "Unspecified error". For the client side, when I right click the chart and select export menu item, capture data dialog is appeared and process from 0-100%, and then FCExporter.swf is shown, but disabled. And it is also same as server side export, it would be fail if clicking the self-created export button, it throws "Unspecified error". Remark: Both codes are hosted in server different server, let say export code in http://code.aaa.com and all resources such as chart swf, fusionCharts.js in http://resouce.aaa.com. thanks for your help. Ryan export.zip Share this post Link to post Share on other sites
srividya_sharma Report post Posted December 30, 2009 Hi Ryan, I was able to replicate the problem here. Settings: Cross domain -> swf and js files on one server and htm/ jsps on another server I am still exploring this. I will get back to you soon. Srividya Share this post Link to post Share on other sites
ryanyu Report post Posted December 30, 2009 Hi Srividya, Thank you very much Ryan Share this post Link to post Share on other sites
srividya_sharma Report post Posted January 2, 2010 Hi Ryan, Found out that, currently, the SWF and export handler page have to be on same sub-domain. Else, cross domain security applies. !!?? Srividya Share this post Link to post Share on other sites
ryanyu Report post Posted January 3, 2010 Hi Srividya, I have tested that SWF and export handler page have to be on same domain, but the html and other jsp pages are on other server. The export event cannot be triggered by clicking the button. Is it a cross domain issue ? If yes, would you guide how to apply cross domain security ? Thanks !!! Ryan Share this post Link to post Share on other sites
srividya_sharma Report post Posted January 4, 2010 Hi Ryan, Any data transfer between an SWF and server (or two SWFs) has to be on same sub-domain. Srividya Share this post Link to post Share on other sites