Success! Looks like we've fixed this one. According to our records the fix was applied for a bug in our system in a recent build.
  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    45
    Vote Rating
    0
    raivis is on a distinguished road

      0  

    Default BorderLayoutContainer ContentPanel expand does not work if executed from code

    BorderLayoutContainer ContentPanel expand does not work if executed from code


    Hello. Just noticed, that if I set up BorderLayoutPanel and populate it with ContentPanel, then ContentPanel's collapse and expand will not work if i execute it from my own code (Toolbutton works as expected).
    rev 1806

    Code:
    public class GxtModule implements EntryPoint {
    
    
        @Override
        public void onModuleLoad() {
            RootPanel rootPanel = RootPanel.get();
    
    
            final BorderLayoutContainer blcMain = new BorderLayoutContainer();
            blcMain.setBorders(true);
    
    
            final ContentPanel cpCenter = new ContentPanel();
            final ContentPanel cpSouth = new ContentPanel();
    
    
            MarginData centerData = new MarginData();
    
    
            BorderLayoutData southData = new BorderLayoutData(100);
            southData.setMargins(new Margins(5));
            southData.setCollapsible(true);
            southData.setSplit(true);
    
    
            blcMain.setCenterWidget(cpCenter, centerData);
            blcMain.setSouthWidget(cpSouth, southData);
    
    
            TextButton btExpander = new TextButton("Colapse/expand");
            btExpander.addDomHandler(new ClickHandler() {
    
    
                @Override
                public void onClick(ClickEvent event) {
                    cpSouth.setExpanded(!cpSouth.isExpanded());
                }
            }, ClickEvent.getType());
    
    
            cpCenter.add(btExpander);
    
    
            blcMain.setWidth(500);
            blcMain.setHeight(500);
            rootPanel.add(blcMain);
        }
    }
    I also noticed, that isExpanded always returns true regardless ContentPanel's state. After running this code ContentPanel is at first collapsed, but when I click the button second time I am getting exception that leads to:
    Code:
    ...Caused by: java.lang.NullPointerException: null
        at com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.onCollapse(BorderLayoutContainer.java:599)
        at com.sencha.gxt.widget.core.client.container.BorderLayoutContainer$Handler.onBeforeCollapse(BorderLayoutContainer.java:228)
    ...
    I also tried to use local boolean variable instead of isExpanded(). Exception does not get triggered but ContentPanel still remains collapsed.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Vote Rating
    88
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Thanks for the report, there is something wrong there, and we'll look into it.

    Here is a workaround that should get you by for now:
    Code:
      @Override  public void onModuleLoad() {
        RootPanel rootPanel = RootPanel.get();
    
    
        final BorderLayoutContainer blcMain = new BorderLayoutContainer();
        blcMain.setBorders(true);
    
    
        final ContentPanel cpCenter = new ContentPanel();
        final ContentPanel cpSouth = new ContentPanel();
    
    
        MarginData centerData = new MarginData();
    
    
        BorderLayoutData southData = new BorderLayoutData(100);
        southData.setMargins(new Margins(5));
        southData.setCollapsible(true);
        southData.setSplit(true);
    
    
        blcMain.setCenterWidget(cpCenter, centerData);
        blcMain.setSouthWidget(cpSouth, southData);
    
    
        TextButton btExpander = new TextButton("Colapse/expand");
        btExpander.addDomHandler(new ClickHandler() {
          private boolean expanded = true;
          @Override
          public void onClick(ClickEvent event) {
            Widget w = blcMain.getSouthWidget();
            if (w instanceof CollapsePanel) {// collapsed, need to expand
              expand((CollapsePanel) w);
            } else {// w instanceof ContentPanel
              ((ContentPanel) w).collapse();
            }
          }
          private native void expand(CollapsePanel w) /*-{
            w.@com.sencha.gxt.widget.core.client.CollapsePanel::onExpandButton()();
          }-*/;
        }, ClickEvent.getType());
    
    
        cpCenter.add(btExpander);
    
    
        blcMain.setWidth(500);
        blcMain.setHeight(500);
        rootPanel.add(blcMain);
      }

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    45
    Vote Rating
    0
    raivis is on a distinguished road

      0  

    Default


    Thanks for the workaround, it's working this way.

  4. #4
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    This is fixed SVN (rev 1953). Change will go out in next release later this week.

  5. #5
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    Fixed in beta 1.