Saturday, March 24, 2012

Canvas Serialization: status: failed

Today after approximately 4 hours of work, I discovered something quite unfortunate. We are unable to serialize Canvases...It took a long time just to figure out how to serialize something using GWT (to do this I had to create a spike for serialization) once I was able to serialize a string, I took to the task of serializing a SmartGWT canvas, this yielded the following result:












Previously, it was my understanding that Ian had already confirmed that serialization of a canvas object was possible, but when I tested his code, I found that what was actually happening was that nothing was being serialized, but instead he was getting java.io* errors, the reason being that you are unable to serialize things client side like he was trying, therefore he never ran into this beautiful error. I believe the reason this went unnoticed was due to the fact that his error gets thrown, and you get output of it, but it gets silently ignored and does not crash the web app. But, once serialization was implemented server side correctly, I found out that it is impossible to serialize a canvas.

      In light of this discovery, I feel that we as a group need to go back to the drawing board concerning how to save our projects. I believe that the only way that we will be able to save projects though will be through a technique of back parsing, where we take our parsed html ( because it can be read in as a string)  and we will serialize that and save it to the server. When the client wants to load their project, we will grab the html, and parse it back into Canvases. How this will work? I have no idea. But here's hoping for the best.......



[EDIT]
I attempted to force a smartGWT canvas to be serializable using this class:

public class CanvasSerializable extends Canvas implements IsSerializable, Serializable {
private static final long serialVersionUID = 5670628250770755450L;
}


but that only gave me a more different error:


1 comment:

  1. Nialls, see if you can write a wrapper that contains all of the things you will want saved. Then, instead use this. On the client side implementation, use a Canvas. On the server side, use a non-canvas implementation. This is how we are saving things we want to draw as Canvases in our project.

    ReplyDelete