Serializing different objects in one class that implements IsSerializable

39 views
Skip to first unread message

coffeMan

unread,
Sep 21, 2012, 10:40:01 AM9/21/12
to google-we...@googlegroups.com
I created a class that implements IsSerializable.  I am using Polygon and LatLng within this class called BoundingBox.  I am getting issues with no being able to instantiate Polygon without a constructor.  Do you create a separate Polygon class?

[ERROR] com.google.gwt.maps.client.overlay.Polygon has no available instantiable subtypes.
                                                                                   &
  [ERROR] subtype com.google.gwt.maps.client.overlay.Polygon is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. 

Can anyone point me in the right direction???

Thanks!

public class BoundingBox implements IsSerializable {

    private LatLng Coordinate_One;
    private LatLng Coordinate_Two;
    private LatLng Coordinate_Three;
    private LatLng Coordinate_Four;
    private Polygon poly;

    public BoundingBox() {        
    }        
    
    public Polygon getPoly() {
        return poly;
    }

    public void setPoly(Polygon poly) {
        this.poly = poly;
    }   

    public Polygon CreatePolygon(BoundingBox bbox) // param = file type object
    {
        LatLng[] polyOverlay = new LatLng[5];
        polyOverlay[0] = LatLng.newInstance(bbox.getCoordinate_One()
                .getLatitude(), bbox.getCoordinate_One().getLongitude());
        polyOverlay[1] = LatLng.newInstance(bbox.getCoordinate_Two()
                .getLatitude(), bbox.getCoordinate_Two().getLongitude());
        polyOverlay[2] = LatLng.newInstance(bbox.getCoordinate_Three()
                .getLatitude(), bbox.getCoordinate_Three().getLongitude());
        polyOverlay[3] = LatLng.newInstance(bbox.getCoordinate_Four()
                .getLatitude(), bbox.getCoordinate_Four().getLongitude());
        polyOverlay[4] = LatLng.newInstance(bbox.getCoordinate_One()
                .getLatitude(), bbox.getCoordinate_One().getLongitude());

        this.poly = new Polygon(polyOverlay);

        return poly;
    }
 public LatLng getCoordinate_One() {
        return Coordinate_One;
    }

    public void setCoordinate_One(LatLng coordinate_One) {
        Coordinate_One = coordinate_One;
    }...etc for the rest of the sets/gets

Paul Robinson

unread,
Sep 21, 2012, 10:58:33 AM9/21/12
to google-we...@googlegroups.com
You don't show the Polygon class, but from the error it looks like you haven't provided a zero-argument constructor. It must have one, even if it's private and you never call it. GWT-RPC needs it for anything that it serializes.

Paul
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/FZ8xY8K6SA0J.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Nick Matviko

unread,
Sep 21, 2012, 11:04:53 AM9/21/12
to google-we...@googlegroups.com
ok so for my createpolygon method i just make that private? You cant make a private constructor of an object in another class, or can you?  And for the polygon class being shown, i am just importing import com.google.gwt.maps.client.overlay.Polygon this. 

Jens

unread,
Sep 21, 2012, 11:19:16 AM9/21/12
to google-we...@googlegroups.com
The Polygon class is a JavaScriptOverlay type provided by Google and it does not have a no-arg constructor, so you can't use it with GWT-RPC. Other than that I assume you can't use JSO's on server side either (How should JSNI work on server side?) so it does not make sense to use them in a serializable class. 

-- J.


Nick Matviko

unread,
Sep 21, 2012, 11:23:26 AM9/21/12
to google-we...@googlegroups.com
Ok, so with that being said, ill need to create my own LatLng and Polygon objects? or?

On Fri, Sep 21, 2012 at 8:19 AM, Jens <jens.ne...@gmail.com> wrote:
The Polygon class is a JavaScriptOverlay type provided by Google and it does not have a no-arg constructor, so you can't use it with GWT-RPC. Other than that I assume you can't use JSO's on server side either (How should JSNI work on server side?) so it does not make sense to use them in a serializable class. 

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
Reply all
Reply to author
Forward
0 new messages