PDA

View Full Version : [FIXED][1.2.3] Composite raises JavascriptException: "elem has no properties"



googelybear
26 Feb 2009, 7:02 AM
Hi,

I wanted to try out the new ext-gwt Composite class, because I thought it would be similar to GWT's composite. However when I run my small sample application (following Composite's javadoc of course) I get the following error:



[ERROR] Unable to load module entry point class layoutTest.client.LayoutTest (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError): elem has no properties
fileName: jar:file:/opt/gwt/gwt-user.jar!/com/google/gwt/dom/client/DOMImpl.java
lineNumber: 117
stack: (null)@jar:file:/opt/gwt/gwt-user.jar!/com/google/gwt/dom/client/DOMImpl.java:117

(...)

at com.google.gwt.dom.client.DOMImpl.getParentElement(Native Method)
at com.google.gwt.dom.client.Element$.getParentElement$(Element.java:181)
at com.google.gwt.user.client.DOM.getParent(DOM.java:885)
at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1300)
at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:464)
at com.extjs.gxt.ui.client.widget.Composite.onAttach(Composite.java:126)
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 layoutTest.client.LayoutTest.onModuleLoad(LayoutTest.java:32)
Here's a minimal code snippet to reproduce this error:



public class LayoutTest implements EntryPoint {

/**
* This is the entry point method.
*/
public void onModuleLoad() {
RootPanel.get("container").add(new NavBar());
}
}
public class NavBar extends Composite {

LayoutContainer container;

public NavBar() {
container = new LayoutContainer();

initComponent(container);
}
}I also read that there is a ComponentComposite - what is the difference between this and Composite?

googelybear
26 Feb 2009, 3:48 PM
Update: When I use the much simpler (in terms of lines of code) ComponentComposite to wrap the LayoutContainer it works as expected.

darrellmeyer
11 Mar 2009, 7:59 PM
Fixed in SVN.

Composite is a GXT Component subclass. ComponentComposite is a GWT Composite subclass. If your internal component is a LayoutContainer I would recommend using the GXT Composite class as it will provide better support with GXT Layouts.

Raziel
15 Apr 2009, 4:49 PM
I get the following error when creating a GXT Composite:

[ERROR] Unable to load module entry point class com.mycomp.gwt.client.TestEntryPoint (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError): 'parentElement' is null or not an object
number: -2146823281
description: 'parentElement' is null or not an object
at com.google.gwt.dom.client.DOMImplIE6.getParentElement(Native Method)
at com.google.gwt.dom.client.Element$.getParentElement$(Element.java:254)
at com.google.gwt.user.client.DOM.getParent(DOM.java:893)
at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1300)
at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:464)
at com.extjs.gxt.ui.client.widget.Composite.onAttach(Composite.java:126)
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:393)
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.mycomp.gwt.client.TestEntryPoint.onModuleLoad(TestEntryPoint.java:60)


- GXT version: 1.2.3
- Host mode
- GWT 1.6
- Windows XP

- Sample code:

public class TestEntryPoint implements EntryPoint {
public void onModuleLoad() {
class TestComposite extends Composite {
public TestComposite() {
LayoutContainer c = new LayoutContainer();
c.add(new Text("Hello GXT"));

initComponent(c);
}
}
RootPanel.get().add(new TestComposite());
}
}

However, when I add a Viewport the hold the Composite instance then it works.

public class TestEntryPoint implements EntryPoint {
public void onModuleLoad() {
class TestComposite extends Composite {
public TestComposite() {
LayoutContainer c = new LayoutContainer();
c.add(new Text("Hello GXT"));

initComponent(c);
}
}
Viewport v = new Viewport();
v.add(new TestComposite());
RootPanel.get().add(v);
}
}

Also, a different but related issue: In the same example tha previously worked, if I replace the LayoutContainer for a VerticalPanel (it could be an HorizontalPanel too),

public class TestEntryPoint implements EntryPoint {
public void onModuleLoad() {
class TestComposite extends Composite {
public TestComposite() {
VerticalPanel c = new VerticalPanel();
c.add(new Text("Hello GXT"));

initComponent(c);
}
}
Viewport v = new Viewport();
v.add(new TestComposite());
RootPanel.get().add(v);
}
}

then I get the following error:

[ERROR] Unable to load module entry point class com.mycomp.gwt.client.TestEntryPoint (see associated exception for details)
java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.Component.isVisible(Component.java:633)
at com.extjs.gxt.ui.client.widget.Component.isVisible(Component.java:633)
at com.extjs.gxt.ui.client.widget.Component.isVisible(Component.java:633)
at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:367)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:455)
at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:238)
at com.extjs.gxt.ui.client.widget.VerticalPanel.onRender(VerticalPanel.java:166)
at com.extjs.gxt.ui.client.widget.Component.render(Component.java:851)
at com.extjs.gxt.ui.client.widget.Composite.onRender(Composite.java:142)
at com.extjs.gxt.ui.client.widget.Component.render(Component.java:851)
at com.extjs.gxt.ui.client.widget.Layout.renderComponent(Layout.java:257)
at com.extjs.gxt.ui.client.widget.layout.FlowLayout.renderComponent(FlowLayout.java:117)
at com.extjs.gxt.ui.client.widget.Layout.renderAll(Layout.java:248)
at com.extjs.gxt.ui.client.widget.Layout.onLayout(Layout.java:228)
at com.extjs.gxt.ui.client.widget.layout.FlowLayout.onLayout(FlowLayout.java:109)
at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:93)
at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:360)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:455)
at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:238)
at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:466)
at com.extjs.gxt.ui.client.widget.Viewport.onAttach(Viewport.java:109)
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:393)
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.mycomp.gwt.client.TestEntryPoint.onModuleLoad(ApplicationBuilder.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:326)
at com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:343)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6.access$300(BrowserWidgetIE6.java:37)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.gwtOnLoad(BrowserWidgetIE6.java:77)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.invoke(BrowserWidgetIE6.java:161)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)


I was expecting all this to work like the regular GWT Composite, where I can create a composite and use any panel (vertical, horizontal, etc.) and just add it to the root Panel (or any other panel) and work.

Is this a bug, or what's the logic behind this that makes the expected behavior not possible?