Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem with loadFromXml or loadFromString methods (Read 5207 times)
cmastrantono
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: Jul 20th, 2011
Problem with loadFromXml or loadFromString methods
Jul 20th, 2011 at 9:30pm
Print Post  
Hi there!

I'm facing a problem working with the JDiagram component, using a JSP, an Applet and some Java code in the backend.

First, I draw something in the applet, then when I click on the "Render as image map", the Diagram data is sent to the server, and then 2 things can happen.

In case 1:
------------
If in my JSP I use applet.saveToString(true); (this is javascript, like the example that comes with de zip) then the diagram data reaches the Java code in the backend in a compressed way (I think) and, when I try to do "diagram.loadFromString(diagramData)" the console shows this:

[code]
com.mindfusion.diagramming.XmlException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

at com.mindfusion.diagramming.Diagram.a(Unknown Source)

at com.mindfusion.diagramming.Diagram.a(Unknown Source)

at com.mindfusion.diagramming.Diagram.loadFromString(Unknown Source)

at com.mindfusion.diagramming.Diagram$loadFromString.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
....
[/code]

Case 2
---------

If in my JSP I use applet.saveToString(false); then the diagram data reaches the Java code in the backend in XML format. Then when I try to do "diagram.loadFromXml(diagramData)" the console shows this:

[code]

[Fatal Error] :1:56: Content is not allowed in prolog.

DiagramData: <?xml version="1.0" encoding="UTF-16" standalone="no"?>
<Diagram Version="14">
<Nodes>
<Node Class="std:ShapeNode" Id="0" Version="1">
<ZIndex>0</ZIndex>
<HyperLink>http://mindfusion.org</HyperLink>
<Brush Id="0"/>
.......
......
.
...
....
</InplaceEditFont>
<ModificationStart>0</ModificationStart>
<ShowToolTips>true</ShowToolTips>
</View>
</Diagram>

imageMapMode: Render as image map
Stacktrace follows:
org.xml.sax.SAXParseException: Content is not allowed in prolog.

at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)

at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)

at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)

at com.mindfusion.diagramming.Diagram.b(Unknown Source)

at com.mindfusion.diagramming.Diagram.loadFromXml(Unknown Source)

at com.mindfusion.diagramming.Diagram$loadFromXml.call(Unknown Source)

at proyectobase.DesignerController$_closure1.doCall(DesignerController.groovy:57)

at proyectobase.DesignerController$_closure1.doCall(DesignerController.groovy)

at java.lang.Thread.run(Thread.java:595)
[/code]
==========

I'm sorry for the HUGE post... hope somebody can help me.

Best regards.

Cristian.


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with loadFromXml or loadFromString met
Reply #1 - Jul 21st, 2011 at 7:17am
Print Post  
Hi,

Is that "DiagramData: " prefix (shown in the second stack trace) a part of the string you pass to loadFromString?

Stoyan
  
Back to top
 
IP Logged
 
cmastrantono
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: Jul 20th, 2011
Re: Problem with loadFromXml or loadFromString met
Reply #2 - Jul 21st, 2011 at 2:25pm
Print Post  
Hi!

Thanks for your response. My answer is no.

The loadFromString or loadFromXml are receiving just a well formed XML or the compressed diagram.

I just sent an email with a txt file with the content of some diagram in the compressed form to support@mindfusion.eu

Maybe you can check it to see whats wrong with that.

Tell me if I can do any else to help you to solve this problem.

Cristian.
  
Back to top
 
IP Logged
 
cmastrantono
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: Jul 20th, 2011
Re: Problem with loadFromXml or loadFromString met
Reply #3 - Jul 21st, 2011 at 4:44pm
Print Post  
This is at least weird, but I found a kind of solution.

In the applet, finally I used the base 64 Format to load data (in the example it comes with SaveToStringFormat.CompressedXml)

[code]
<applet id="diag" ...
...
<param name='DiagramData' value='<% diagram.saveToString(SaveToStringFormat.Base64, false)%>' >
...
[/code]


Then in the Script section of the JSP, I saved the applet data in this way (instead of "applet.saveToString(true);")

[code]
applet.getDiagram().saveToString();
[/code]

It seems that the "saveToString" method of the applet does not save the data in base 64 format, but it does in a XML or Compressed XML format. Then when the Diagram objetct in the Java code tries to load the data from String, it expects some Base 64 data instead of the XML data that finally receives. I think this is the main razon of my problem. So, using the saveToString method of the Diagram object instead of the one in the applet everything seems to be fine.

Let me know if I miss something or some of my reasoning is wrong.

Best regards.

Cristian.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with loadFromXml or loadFromString met
Reply #4 - Jul 21st, 2011 at 6:02pm
Print Post  
We use the applet methods to exchange data with our ASP.NET control (it shows the applet as a front-end), and it seems that's done in UTF-8. I can see the loadFromString code has cases for both UTF-8 and UTF-16, but for some reason both throw exceptions with your string. Our developer will debug this tomorrow. On what OS and JRE version have you saved it?
  
Back to top
 
IP Logged
 
cmastrantono
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: Jul 20th, 2011
Re: Problem with loadFromXml or loadFromString met
Reply #5 - Jul 21st, 2011 at 9:32pm
Print Post  
I'm using Win XP SP3 and JRE 1.6.0_26-b03

Cristian.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with loadFromXml or loadFromString met
Reply #6 - Aug 15th, 2011 at 5:25pm
Print Post  
The latest version here should let you use the applet methods:
https://www.mindfusion.eu/JDiagramTrial.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint