Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    AssertionError: A widget that has an existing parent widget

    Hi

    I'm trying to add gwt components to smartGwt tabs. But It's throwing runtime assertion error.

    Uncaught JavaScript exception [uncaught exception: java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list] in , line 0

    I did lot of ground worklike

    1) Calling draw on smartTabSet after attaching root.
    Throws :
    Adding already drawn widget:isc_OID_21 to new parent:isc_OID_22. Child has been cleared so it can be drawn inside the new parent.

    2) Shuffling the component creation.

    3) Adding to smartGwt wrappers

    But no use. This case is loading the tabs. But when I select second tab, the assertion error is coming. I'm following similar posts in this forum.

    Please let me know how can add simple smartGWT Tabs to RootPanel.

    my samplecode:
    --------------------
    TabSet tabSet = new TabSet();
    HLayout wrapper = new HLayout();


    wrapper.setWidth100();

    tabSet.setWidth(580);
    tabSet.setHeight(400);

    Tab smartTab1 = new Tab("GWT Tab");
    Canvas tabPane1 = new Canvas();
    tabPane1.setWidth100();
    tabPane1.setHeight100();
    tabPane1.addChild(new com.google.gwt.user.client.ui.Label("hi-tab1"));
    smartTab1.setPane(tabPane1);

    Tab smartTab2 = new Tab("Another Tab");
    Canvas tabPane2 = new Canvas();
    tabPane2.setWidth100();
    tabPane2.setHeight100();
    tabPane2.addChild(new com.google.gwt.user.client.ui.Label("hi-tab2"));
    smartTab2.setPane(tabPane2);

    tabSet.setTabs(smartTab2, smartTab1);
    tabSet.selectTab(0);

    wrapper.addMember(tabSet);

    tabSet.draw();

    RootPanel.get().add(wrapper);
    tabPane1.redraw();

    -------------
    -raghu

    #2
    Don't use RootPanel.get().add(wrapper); instead use wrapper.draw() only, and you don't need that redraw call nor the tabset.draw() call. BTW this has been posted in the forums multiple times before.

    Comment


      #3
      hi svjard

      thanks for your reply. yes it's working, it's just floating on top of the page. but i need to display this tabs inside a gwt division/html division.
      please let me know how we can attach to a parent.

      -raghu

      Comment


        #4
        Well you can use RootPanel.get().add(wrapper); but only that not repeteated draw calls like before. Is that the only thing your adding to the Root?

        Comment


          #5
          I'm adding other components to the root, along with the tabSet, like below:

          1. wrapper.addMember(tabSet);
          2. wrapper.draw(); //only once
          3. RootPanel.get().add(wrapper);

          But Assertion error still exists. I called draw after line 3. But no change.

          -raghu

          Comment


            #6
            Remove #2 all together. You don't want both 2 and 3.

            Comment


              #7
              svjard,

              if we remove 3,2 then , How can we position the wrapper inside a division , like

              RootPanel.get("tabDiv").add(wrapper);

              just wrapper.draw() is showing the wrapper on top of other widgets. I want to place tabs inside a particular division in the RootPanel (along with other components).

              Please suggest me.

              -raghu

              Comment


                #8
                Your not quite understanding, here is the code.
                Code:
                 TabSet tabSet = new TabSet();
                 HLayout wrapper = new HLayout();
                
                
                 wrapper.setWidth100();
                
                 tabSet.setWidth(580);
                 tabSet.setHeight(400);
                
                 Tab smartTab1 = new Tab("GWT Tab");
                 Canvas tabPane1 = new Canvas();
                 tabPane1.setWidth100();
                 tabPane1.setHeight100();
                 tabPane1.addChild(new com.google.gwt.user.client.ui.Label("hi-tab1"));
                 smartTab1.setPane(tabPane1);
                
                 Tab smartTab2 = new Tab("Another Tab");
                 Canvas tabPane2 = new Canvas();
                 tabPane2.setWidth100();
                 tabPane2.setHeight100();
                 tabPane2.addChild(new com.google.gwt.user.client.ui.Label("hi-tab2"));
                 smartTab2.setPane(tabPane2);
                
                 tabSet.setTabs(smartTab2, smartTab1);
                 tabSet.selectTab(0);
                
                 wrapper.addMember(tabSet);
                
                 RootPanel.get("mydiv").add(wrapper);

                Comment


                  #9
                  I'm sorry svjard. I did the same way as above. And I recompiled your code. It's throwing Assertion Error. That is the problem. Two tabs are visible at the given 'mydiv' , but when I click on the second tab assertion error is coming. And empty tab is getting displayed.

                  Please suggest me. I know this is very rare case, but I need to fix this.

                  -raghu

                  Comment


                    #10
                    Oh ok now were getting somewhere, I thought your expection was from the draw() but your getting it when switching tabs. That is to be expected again your solution is to use just tabSet.draw(). I think if you want to add to a parent you need another approach, such as using a Layout with an ID and encapsultating all the other widgets your adding within that layout.

                    Comment


                      #11
                      Could you please give me some code sample, this could be helpful many people like me.

                      Or is there any sample available in showcase.

                      -raghu

                      Comment


                        #12
                        Well give me snippet of what all your trying to add to the Root and then I can give you an example that better pertains to your situation.

                        Comment


                          #13
                          Svjard,

                          Please look at the following class , this is similar entry point for my application. I'm using same set of implementation in all the other pages. So I'm giving you basic page, which contains header(contains gwt/sgwt widgets). Followed by a tabSet which contains other visuals.



                          Code:
                          public class Sample implements EntryPoint {
                          		public void onModuleLoad() {
                          			 RootPanel.get("head").add(new Label("Welcome Page"));
                          			TabSet tabSet = new TabSet();
                          			 HLayout wrapper = new HLayout();
                          
                          
                          			 wrapper.setWidth100();
                          
                          			 tabSet.setWidth(580);
                          			 tabSet.setHeight(400);
                          
                          			 Tab smartTab1 = new Tab("GWT Tab");
                          			 Canvas tabPane1 = new Canvas();
                          			 tabPane1.setWidth100();
                          			 tabPane1.setHeight100();
                          			 tabPane1.addChild(new com.google.gwt.user.client.ui.Label("hi-tab1"));
                          			 smartTab1.setPane(tabPane1);
                          
                          			 Tab smartTab2 = new Tab("Another Tab");
                          			 Canvas tabPane2 = new Canvas();
                          			 tabPane2.setWidth100();
                          			 tabPane2.setHeight100();
                          			 tabPane2.addChild(new com.google.gwt.user.client.ui.Label("hi-tab2"));
                          			 smartTab2.setPane(tabPane2);
                          
                          			 tabSet.setTabs(smartTab2, smartTab1);
                          			 tabSet.selectTab(0);
                          
                          			 wrapper.addMember(tabSet);
                          
                          			 RootPanel.get("mydiv").add(wrapper);
                          		}
                          	
                          }
                          -raghu

                          Comment


                            #14
                            Well again I don't exactly know why you need "head" and "mydiv" how do you use those later on? You can easily modify your example.
                            Code:
                            VLayout layout = new VLayout();
                            layout.setID("myLayout");
                            layout.setWidth100();
                            layout.setHeight100();
                            
                            layout.addMember(new Label("Welcome Page"));
                            TabSet tabSet = new TabSet();
                            HLayout wrapper = new HLayout();
                            
                            wrapper.setWidth100();
                            
                            tabSet.setWidth(580);
                            tabSet.setHeight(400);
                            
                            Tab smartTab1 = new Tab("GWT Tab");
                            Canvas tabPane1 = new Canvas();
                            tabPane1.setWidth100();
                            tabPane1.setHeight100();
                            tabPane1.addChild(new com.google.gwt.user.client.ui.Label("hi-tab1"));
                            smartTab1.setPane(tabPane1);
                            
                            Tab smartTab2 = new Tab("Another Tab");
                            Canvas tabPane2 = new Canvas();
                            tabPane2.setWidth100();
                            tabPane2.setHeight100();
                            tabPane2.addChild(new com.google.gwt.user.client.ui.Label("hi-tab2"));
                            smartTab2.setPane(tabPane2);
                            
                            tabSet.setTabs(smartTab2, smartTab1);
                            tabSet.selectTab(0);
                            
                            wrapper.addMember(tabSet);
                            
                            layout.addMember(wrapper);
                            
                            layout.draw();

                            Comment


                              #15
                              Yes, It's woking fine. But tabs are appearing leftside of the page. I did few css tricks, but the header is following css alignments, but tabs are there in the leftside. How to adjust the position of the tabs inside the vlayout. Or I can go for grid?

                              Please suggest.

                              Thanks for your support. I'm able to fix this issue. I was struggling with this for past two days.

                              -raghu

                              Comment

                              Working...
                              X