PDA

View Full Version : [CLOSED] problems when trying to add a dialog to an absolut panel



rgpinheiro
1 Jul 2008, 6:17 AM
when I try to add a dialog to an absolut panel I get the following error:

java.lang.NullPointerException
at com.google.gwt.dev.shell.ModuleSpace.invokeNative (ModuleSpace.java: 443)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid (ModuleSpace.java: 235)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid (JavaScriptHost.java: 107)
AT com.extjs.gxt.ui.client.util.WidgetHelper.doAttachNative (WidgetHelper.java)
at com.extjs.gxt.ui.client.util.WidgetHelper.doAttach (WidgetHelper.java: 22)
at com.extjs.gxt.ui.client.widget.Container.doLayout (Container.java: 256)
at com.extjs.gxt.ui.client.widget.Container.layout (Container.java: 339)
at com.extjs.gxt.ui.client.widget.LayoutContainer.layout (LayoutContainer.java: 237)
at com.extjs.gxt.ui.client.widget.Container.onAttach (Container.java: 346)
at com.google.gwt.user.client.ui.Widget.setParent (Widget.java: 231)
at com.google.gwt.user.client.ui.Panel.adopt (Panel.java: 119)
at com.google.gwt.user.client.ui.ComplexPanel.add (ComplexPanel.java: 86)
at com.google.gwt.user.client.ui.AbsolutePanel.add (AbsolutePanel.java: 80)
at com.extjs.gxt.ui.client.widget.Window.show (Window.java: 618)

And I have these methods:

public void show() {
createWestPanel();
createCenterPanel();
createMenu();
createValidator();
createDefaultButtons();

super.show();
}

private void createValidator() {
this.validator = new Validator();
}

private void createCenterPanel() {
centerPanel = new ContentPanel();
centerPanel.setFrame(true);

BorderLayoutData data = new BorderLayoutData(LayoutRegion.CENTER);
add(centerPanel, data);
layout();
}

private void createWestPanel() {
westPanel = new ContentPanel();

BorderLayoutData data = new BorderLayoutData(LayoutRegion.WEST, 150, 100, 300);
data.setMargins(new Margins(0, 5, 0, 0));
data.setSplit(true);;
data.setFloatable(true);
data.setCollapsible(true);
add(westPanel, data);
layout();
}

darrellmeyer
1 Jul 2008, 8:58 AM
You cannot add windows to any panels. You simply create, then call show().

rgpinheiro
1 Jul 2008, 9:09 AM
Really sorry... I expressed wrong:

I'm trying to add an absolut panel within a dialog...

darrellmeyer
1 Jul 2008, 9:39 AM
You need to provide test code in this format (http://www.extjs.com/forum/showthread.php?t=33778). If your test code is a Dialog subclass, you should not be overriding the show() method. Take a look at any of the example dialog code to see the proper usage.

rgpinheiro
1 Jul 2008, 12:51 PM
solved by placing the methods of creating menu items, buttons and panels of dialog in the method onResize.

I really don't understand, Why I can't overwrite the method show( ).....

darrellmeyer
2 Jul 2008, 7:01 AM
You should create your panels in the constructor or onRender, not onResize.

rgpinheiro
2 Jul 2008, 9:08 AM
very good :)

worked correctly
thanks Darrell