User (Legacy) Posted September 23, 2004 Report Share Posted September 23, 2004 Hi. We're thinking about using ChartFX in our product and I have a technical question. We want to keep templates on disk in XML. However, we dson't want to incur the hit of reading the XML from disk and parsing it every time we want to create a chart. My idea is to create a single ChartServer and read in the XML once and then store it in session (we're in J2EE). Then, when we want to create a map, clone() the ChartServer, set the data and other variable properties, and create a chart. Will this work? Is there a better solution? Thanks, Derek Richardson Appian Corporation Link to comment Share on other sites More sharing options...
User (Legacy) Posted September 23, 2004 Author Report Share Posted September 23, 2004 > create a map, clone() the ChartServer, set the data and other variable Whoops, "map" should be "chart" "Derek Richardson" <derek.richardson@appiancorp.com> wrote in message news:unEbDHZoEHA.3352@webserver3.softwarefx.com... > Hi. We're thinking about using ChartFX in our product and I have a technical > question. > > We want to keep templates on disk in XML. However, we dson't want to incur > the hit of reading the XML from disk and parsing it every time we want to > create a chart. My idea is to create a single ChartServer and read in the > XML once and then store it in session (we're in J2EE). Then, when we want to > create a map, clone() the ChartServer, set the data and other variable > properties, and create a chart. Will this work? Is there a better solution? > > Thanks, > > Derek Richardson > Appian Corporation > > Link to comment Share on other sites More sharing options...
Software FX Posted September 24, 2004 Report Share Posted September 24, 2004 Dear Derek, Cloning is not the best solution for you. Niether do we work well on the native java serialize engine (Externalizable, Serializeable...). The best thing for you to do is use the internal serialize option within chartfx. The way you do this is very simple: Using the CFX for Java export function export to a binary stream and save that stream in session as you suggest. Then create a new ChartServer object, seek to the beginning of the stream and then use the import form a binary stream and boom you have your state restored. Pseudo Code: ByteArrayOutputStream outStream = new ByteArrayOutputStream(); _chart.exportChart(FileFormat.BINARY, outStream); outStream.close(); byte [] byteArray = outStream.toByteArray(); // store this byteArray for later then issue import! ByteArrayInputStream inStream = new ByteArrayInputStream(byteArray); _chart.importChart(FileFormat.BINARY, inStream); Before issuing the import/export you might want to only export certain information. Please see the FileMask API. -cjs "Derek Richardson" <derek.richardson@appiancorp.com> wrote in message news:unEbDHZoEHA.3352@webserver3.softwarefx.com... > Hi. We're thinking about using ChartFX in our product and I have a > technical > question. > > We want to keep templates on disk in XML. However, we dson't want to incur > the hit of reading the XML from disk and parsing it every time we want to > create a chart. My idea is to create a single ChartServer and read in the > XML once and then store it in session (we're in J2EE). Then, when we want > to > create a map, clone() the ChartServer, set the data and other variable > properties, and create a chart. Will this work? Is there a better > solution? > > Thanks, > > Derek Richardson > Appian Corporation > > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.