Problem DockPanel.remove(), DockPanel.clear()

161 views
Skip to first unread message

Evan Tice

unread,
Aug 14, 2006, 1:47:18 PM8/14/06
to Google Web Toolkit
Hey again,

I removed an earlier post I made on this topic which had inprecise
information.

Since I upgrade to 1.1.0, I've been having issues with both
DockPanel.clear() and DockPanel.remove(). I have glanced over the
documentation without finding anything to suggest that I'm doing
something stupid, but as some of my earlier mistakes show, that doesn't
mean anything.

Here's a typical exception:

---- Begin quote ----

[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: JavaScript TypeError
exception: 'null' is null or not an object
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:396)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeVoid(ModuleSpaceIE6.java:283)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:127)
at
com.google.gwt.user.client.impl.DOMImpl.removeChild(DOMImpl.java:230)
at com.google.gwt.user.client.DOM.removeChild(DOM.java:736)
at com.google.gwt.user.client.ui.Panel.disown(Panel.java:75)
at
com.google.gwt.user.client.ui.ComplexPanel.remove(ComplexPanel.java:39)
at com.google.gwt.user.client.ui.DockPanel.remove(DockPanel.java:155)


---- End quote ----

I'm having the same issue with clear as it also calls disown(). The
problem (Panel.disown()) appears to arise from the fact that
DOM.getParent returns null for the widget being removed. Here's the
snippet:

---- From Panel.class ----

protected void disown(Widget w) {
// Only disown it if it's actually contained in this panel.
if (w.getParent() != this) {
throw new IllegalArgumentException("w is not a child of this
panel");
}

// Remove it at the DOM and GWT levels.
Element elem = w.getElement();
DOM.removeChild(DOM.getParent(elem), elem); //!!!--- FAILS
HERE---!!!
w.setParent(null);
}

---- End quote ----

It's quite possible that I'm doing something stupid again. If so, my
apologies :)

Thanks in advance,

Evan

wylp...@gmail.com

unread,
Aug 14, 2006, 10:52:28 PM8/14/06
to Google Web Toolkit
/**
* Adds a widget to the specified edge of the dock.
*
* @param widget the widget to be added
* @param direction the widget's direction in the dock
*/
public void add(Widget widget, DockLayoutConstant direction) {
// Ensure that a second 'center' widget is not being added.
if (direction == CENTER) {
if (center != null)
throw new IllegalArgumentException("Only one CENTER widget may
be added");
center = widget;
}

widget.setLayoutData(new LayoutData(direction));
setCellHorizontalAlignment(widget, horzAlign);
setCellVerticalAlignment(widget, vertAlign);
deferRealize();

// Passing a null container element to add will keep it from being
added
// to the DOM just now. This only works correctly because DockPanel
// implements its own onAttach() logic to ensure that its children
are
// notified of being attached when appropriate.
//super.add(widget,null);
super.add(widget, getElement());
}

wylp...@gmail.com

unread,
Aug 15, 2006, 3:23:47 AM8/15/06
to Google Web Toolkit
up is error

this is ok! I try it!

public abstract class Panel extends Widget implements HasWidgets {

...............

/**
* This method must be called whenever a Widget is removed. It
ensures that
* the Widget's parent is cleared.
*
* @param w the widget to be disowned
*/


protected void disown(Widget w) {
// Only disown it if it's actually contained in this panel.
if (w.getParent() != this) {
throw new IllegalArgumentException("w is not a child of this
panel");
}

// Remove it at the DOM and GWT levels.
Element elem = w.getElement();

if(DOM.getParent(elem) != null)
{
DOM.removeChild(DOM.getParent(elem), elem);
}
w.setParent(null);
}
..................................
}

Evan Tice

unread,
Aug 16, 2006, 8:35:24 AM8/16/06
to Google Web Toolkit
So there is a bug?

Brian Glick

unread,
Aug 23, 2006, 2:22:34 PM8/23/06
to Google Web Toolkit
+1

I'm also getting this error in similar situations.

Reply all
Reply to author
Forward
0 new messages