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
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());
}
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);
}
..................................
}
I'm also getting this error in similar situations.