You found a bug! We've classified it as EXTGWT-3005 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium Member
    Join Date
    Nov 2008
    Posts
    102
    Vote Rating
    1
    scaswell1 is on a distinguished road

      0  

    Default AccordionPanel add error

    AccordionPanel add error


    Hello,

    When attempting to add a ContentPanel to an AccordionLayoutContainer, I get the following error:

    Code:
    java.lang.AssertionError: Method must be called before the widget is rendered
    	at com.sencha.gxt.widget.core.client.Component.assertPreRender(Component.java:1197)
    	at com.sencha.gxt.widget.core.client.ContentPanel.setCollapsible(ContentPanel.java:543)
    	at com.sencha.gxt.widget.core.client.container.AccordionLayoutContainer.onInsert(AccordionLayoutContainer.java:305)
    	at com.sencha.gxt.widget.core.client.container.Container.insert(Container.java:400)
    	at com.sencha.gxt.widget.core.client.container.InsertResizeContainer.insert(InsertResizeContainer.java:27)
    	at com.sencha.gxt.widget.core.client.container.Container.add(Container.java:88)
    It seems that when adding a child to an AccordionLayoutContainer, the add method makes sure the child is collapsible, which is apparently only allowed during pre-render. This severely inhibits the ability to add items to an accordion layout container dynamically. Any hints?

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Is it possible that your ContentPanel was already used somewhere else before and so it was already attached once?

    Currently there is a check in place for this. However in GXT 3 this also might be possible to be a runtime change that should always be possible. I will move this thread to the bugs forum for investigation.

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2008
    Posts
    102
    Vote Rating
    1
    scaswell1 is on a distinguished road

      0  

    Default


    Hi Sven,

    I am sure that the ContentPanels being added are brand-new.
    Pseudo code for my use case is as follows:

    Code:
    Viewport v = new Viewport();
    v.setWidget(new BorderLayoutContainer());
    v.getWidget().setWestWidget(new AccordionLayoutContainer());
    RootPanel.get().add(viewport);
    
    // ... some processing goes on ...
    
    for (some_item in some_list) {
         ContentPanel newPane = ... // processing of some_item results in a new panel
        v.getWidget().getWestWidget().add(newPane);
    }
    I can try to make a testcase for you at some point today, if you would like.

  4. #4
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    OK, as workaround, can you try to add the viewport after your precessing?

  5. #5
    Sencha Premium Member
    Join Date
    Nov 2008
    Posts
    102
    Vote Rating
    1
    scaswell1 is on a distinguished road

      0  

    Default


    Yeah, if I add the panels before adding the Viewport to the RootPanel, everything works fine. It was just inconvenient, not as much as a show stopper (in this use-case, anyway.)

  6. #6
    Ext GWT Premium Member dardison's Avatar
    Join Date
    Apr 2008
    Location
    Buenos Aires, Argentina
    Posts
    174
    Vote Rating
    1
    dardison is on a distinguished road

      0  

    Default


    Any news on this issue?

    I was having same problem adding ContentPanel to AccordionLayoutContainer in GXT 3.1.1.I debug the code and it looks like the ContentPanel was attached before the setCollapsible method of it was called so pre-render assertion fail raise.
    This method of AccordionLayoutContainer:

    Code:
      
    @Override  protected void onInsert(int index, Widget child) {
                              super.onInsert(index, child);
                              assert child instanceof ContentPanel : "AccordionLayoutContainer must be ContentPanels"; 
                              ContentPanel cp = (ContentPanel) child;    cp.addBeforeExpandHandler(handler);  
                              cp.addExpandHandler(handler);    cp.setCollapsible(true);    
                              cp.setHideCollapseTool(hideCollapseTool);
                              cp.setAnimCollapse(false); 
                              cp.setTitleCollapse(titleCollapse);
      }
    was called after the panel was attached on the super.insert(...) so it fails.

  7. #7
    Sencha - GXT Dev Team
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    492
    Vote Rating
    15
    branflake2267 will become famous soon enough

      0  

    Default


    Thanks for reporting. I've linked up the issue. We will update this thread on progress.
    Thanks,
    Brandon
    GXT Support

    ~ New GXT Guides ~
    http://docs.sencha.com/gxt/3.1/

    ~ Support Tickets ~
    https://support.sencha.com/index.php

    ~ Tips and Announcements Community ~
    https://plus.google.com/communities/110447085143928405373

    ~Training~
    Get on the Fast Track with Sencha Training http://sencha.com/training

  8. #8
    Sencha - GXT Dev Team
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    492
    Vote Rating
    15
    branflake2267 will become famous soon enough

      0  

    Default


    The issue occurs when adding a content panel on to the accordion after it's rendered. To dynamically fix this, the accordion would have to be removed from parent, rebuilt and then re-added which would render it with the new panel. In other words we don't currently support adding it once its rendered, but have support for rebuilding and adding it.

    At the moment I don't have any workarounds b/c the assertion happens in the component.
    Thanks,
    Brandon
    GXT Support

    ~ New GXT Guides ~
    http://docs.sencha.com/gxt/3.1/

    ~ Support Tickets ~
    https://support.sencha.com/index.php

    ~ Tips and Announcements Community ~
    https://plus.google.com/communities/110447085143928405373

    ~Training~
    Get on the Fast Track with Sencha Training http://sencha.com/training