Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

GWT widget inside smartGWT component

$
0
0
Hello,

I'm currently working on web application using GWT+smartGWT for my master diploma. But I encountered obstacle, that I have trouble overcoming. The situation is like following:

I have an Entry Point, where I have a skeleton for layout of my app(code below):

Code:

public class webPanel implements EntryPoint {
 
  private static final int NORTH_HEIGHT = 99;
  private VLayout mainLayout;       
  private HLayout northLayout; 
  public static HLayout southLayout;
  private VLayout eastLayout; 
  public static VLayout westLayout;

  private final Messages messages = GWT.create(Messages.class); 

  public void onModuleLoad() {

        mainLayout = new VLayout();
            mainLayout.setWidth100(); 
            mainLayout.setHeight100(); 
           
            northLayout = new HLayout(); 
            northLayout.setHeight(NORTH_HEIGHT);

            VLayout vLayout = new VLayout();
            vLayout.addMember(new MasterHead());
            northLayout.addMember(vLayout);
           
            westLayout = new WelcomeView();

            eastLayout = new MapView();
           
            southLayout = new HLayout();

            southLayout.setMembers(westLayout, eastLayout); 

            mainLayout.addMember(northLayout); 
            mainLayout.addMember(southLayout);
 
            RootLayoutPanel.get().add(mainLayout);
         
         
  }

In my class MapView I want to add to smartGWT VLayout MapWidget from GWT-OpenLayers. Code extract for that is enclosed below:

Code:

public class MapView extends VLayout {

        private MapWidget mapWidget = null;
        private static final Projection DEFAULT_PROJECTION = new Projection(
            "EPSG:4326");
       
  public MapView() {
        super();
       
        this.setWidth("*");
   
        MapOptions defaultMapOptions = new MapOptions();
    mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
   
    OSM osmMapnik = OSM.Mapnik("Mapnik");
    OSM osmCycle = OSM.CycleMap("CycleMap");

    osmMapnik.setIsBaseLayer(true);
    osmCycle.setIsBaseLayer(true);

    mapWidget.getMap().addLayer(osmMapnik);
    mapWidget.getMap().addLayer(osmCycle);
     
    LonLat lonLat = new LonLat(6.95, 50.94);
    lonLat.transform("EPSG:4326", mapWidget.getMap().getProjection()); mapWidget.getMap().setCenter(lonLat, 12);
   
        //here is the line causing error
        this.addMember(mapWidget);

  }
}

But when I want to enter page with MapView I get following error on console in Eclipse:

Uncaught JavaScript exception [Uncaught java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list] in http://127.0.0.1:8888/webPanel.html?gwt.codesvr=127.0.0.1:9997, line 5

I tried also this combinations, but with no success:
Code:

Canvas c2 = new Canvas();
    c2.addChild(mapWidget);
    this.addChild(c2);*/
//or this   
this.draw();

It looks like I'm having trouble with adding GWT widget into smartGWT component. Any suggestions how can I fix this?

I don't know how it happened, but before I could run this code without any errors. Scarcely this started showing up.

Information:
SmartClient Version: v9.0_2013-07-03/LGPL Development Only (built 2013-07-03)
Browser: Google Chrome 35.0.1916.153 (Official Build 274914)
Thanks in advance for any hints/remarks how I can fix this error.

Regards,
Jakub

Viewing all articles
Browse latest Browse all 4756

Trending Articles