Results 1 to 4 of 4

Thread: [FNR] NPE appears after container is removed and then added into DOM in GXT 2.1.1

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    Jun 2010
    Posts
    2
    Vote Rating
    0
      0  

    Default [FNR] NPE appears after container is removed and then added into DOM in GXT 2.1.1

    Hi GXT team and community,

    we faced with a NPE problem when we try to add a field into form that belong to container in a special state.
    The container is removed from DOM and then added back.

    Exception occurs in both web mode and compiled modes and we mostly use Firefox and Chrome.

    Code:
    java.lang.NullPointerException: null
        at com.extjs.gxt.ui.client.widget.layout.FormLayout.renderField(FormLayout.java:338)
        at com.extjs.gxt.ui.client.widget.layout.FormLayout.renderComponent(FormLayout.java:307)
        at com.extjs.gxt.ui.client.widget.Layout.renderAll(Layout.java:353)
        at com.extjs.gxt.ui.client.widget.Layout.onLayout(Layout.java:318)
        at com.extjs.gxt.ui.client.widget.layout.AnchorLayout.onLayout(AnchorLayout.java:99)
        at com.extjs.gxt.ui.client.widget.layout.FormLayout.onLayout(FormLayout.java:267)
        at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:114)
        at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:351)
        at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:444)
        at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:245)
        at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:427)
        at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:240)
        at com.example.client.Test$1.componentSelected(Test.java:33)
        at com.example.client.Test$1.componentSelected(Test.java:1)
        at com.extjs.gxt.ui.client.event.SelectionListener.handleEvent(SelectionListener.java:20)
        at com.extjs.gxt.ui.client.event.SelectionListener.handleEvent(SelectionListener.java:1)
        at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178)
        at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
        at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:462)
        at com.extjs.gxt.ui.client.widget.button.Button.onClick(Button.java:577)
        at com.extjs.gxt.ui.client.widget.button.Button.onComponentEvent(Button.java:285)
        at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:876)
        at com.extjs.gxt.ui.client.widget.form.AdapterField.onBrowserEvent(AdapterField.java:88)
        at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1307)
        at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1263)
    Simple code to reproduce the problem

    Code:
    public class Test implements EntryPoint {
        public void onModuleLoad() {
            final TabPanel tabs = new TabPanel();
            final TabItem item = new TabItem("Item 1");
            item.setLayout(new FitLayout());
            final TabItem item2 = new TabItem("Item 2");
            final FormData layoutData = new FormData("-20");
            
            final LayoutContainer container = new LayoutContainer(new FormLayout());
            container.add(new TextField<String>(),layoutData);
            container.add(new AdapterField(new Button("Click",new SelectionListener<ButtonEvent>() {
                @Override
                public void componentSelected(ButtonEvent ce) {
                    tabs.removeAll();
                    tabs.add(item2);
                    tabs.add(item);
                    
                    container.add(new TextField<String>(),layoutData);
                    container.layout();
                }
            })),layoutData);
            item.add(container);
            
            tabs.add(item);
            tabs.add(item2);
            
            RootPanel.get().add(tabs);
        }
    }
    At the moment we cannot find a workaround so any help is highly appreciated.

    Thanks,
    Slava V

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    I run the code against the latest SVN version and it works as expected. Marking this as closed. So this is probably already fixed

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    Please also note that you are calling layout on a container while it is not visible. you should never do that.

  4. #4
    Ext User
    Join Date
    Jun 2010
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Sven,

    thanks for the quick reply. we found a solution by deferring call to layout.

    Best regards,
    Slava V

Similar Threads

  1. [FNR] [2.1.1] NPE in Menu class in Desktop
    By mariusz.pala in forum Ext GWT: Bugs (2.x)
    Replies: 4
    Last Post: 27 Apr 2010, 1:23 AM
  2. [FNR] NPE on FormPanel.clear()
    By ArtemBovin in forum Ext GWT: Bugs (2.x)
    Replies: 1
    Last Post: 9 Mar 2010, 2:06 PM
  3. [FNR] Unrendered field throwing NPE on removeInputStyleName
    By Luming Lai in forum Ext GWT: Bugs (1.x)
    Replies: 1
    Last Post: 19 Jul 2009, 9:31 AM
  4. Replies: 1
    Last Post: 30 Apr 2009, 8:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •