[ERROR] Uncaught exception escaped
java.lang.RuntimeException: JavaScript method
'@com.google.gwt.user.client.impl.DOMImpl::removeChild(Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/Element;)'
threw an exception
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:394)
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:222)
at com.google.gwt.user.client.DOM.removeChild(DOM.java:716)
at
com.google.gwt.user.client.ui.HTMLTable.removeWidget(HTMLTable.java:957)
at
com.google.gwt.user.client.ui.HTMLTable.internalClearCell(HTMLTable.java:829)
at
com.google.gwt.user.client.ui.HTMLTable.cleanCell(HTMLTable.java:915)
at
com.google.gwt.user.client.ui.HTMLTable.removeRow(HTMLTable.java:882)
at
com.google.gwt.user.client.ui.FlexTable.removeRow(FlexTable.java:166)
Caused by: com.google.gwt.core.client.JavaScriptException: JavaScript
Error exception: Argumento no válido.
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at
com.google.gwt.dev.shell.ModuleSpace.createJavaScriptException(ModuleSpace.java:267)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.exceptionCaught(ModuleSpaceIE6.java:105)
at
com.google.gwt.dev.shell.JavaScriptHost.exceptionCaught(JavaScriptHost.java:31)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
I think is a bug in GWT. Thanks
use grid.resizeRows(newRowCount);
If I remove the 2nd-last row from FlexTable, the cells of last row are
NULL. The real last row will not be moved up automatically. Then when I
use getWidget(lastIndex, 0) to access the widiget following the removed
row, GWT said outof bounds...
Javascript Error :
[ERROR] Uncaught exception escaped
java.lang.RuntimeException: JavaScript method
'@com.google.gwt.user.client.impl.DOMImpl::removeChild(Lcom/google/gwt/user/client/Element;Lcom/google/gwt/user/client/Element;)'
threw an exception
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:394)
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:222)
at com.google.gwt.user.client.DOM.removeChild(DOM.java:716)
at
com.google.gwt.user.client.ui.HTMLTable.removeWidget(HTMLTable.java:957)
at
com.google.gwt.user.client.ui.HTMLTable.internalClearCell(HTMLTable.java:829)
at
com.google.gwt.user.client.ui.HTMLTable.cleanCell(HTMLTable.java:915)
at
com.google.gwt.user.client.ui.HTMLTable.removeRow(HTMLTable.java:882)
at
com.google.gwt.user.client.ui.FlexTable.removeRow(FlexTable.java:166)
Caused by: com.google.gwt.core.client.JavaScriptException: JavaScript
Error exception: Invalid argument.
at
com.google.gwt.dev.shell.ModuleSpace.createJavaScriptException(ModuleSpace.java:267)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.exceptionCaught(ModuleSpaceIE6.java:105)
at
com.google.gwt.dev.shell.JavaScriptHost.exceptionCaught(JavaScriptHost.java:31)
at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:127)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:487)
A simple answer is to simply delete the last row until there are no
more rows. THis works.
here is codes to fix this bug. hope GWT can fix this bug in next
release.
public static void removeRow(FlexTable grid, int row) {
Map map = new HashMap();
for (Iterator iter = grid.iterator(); iter.hasNext();) {
Widget w = (Widget) iter.next();
int rowIndex = getRowIndex(w);
if (rowIndex > row){
map.put(myComputeKey(rowIndex-1, getColumnIndex(w)), w);
}
}
for (Iterator iter = map.values().iterator(); iter.hasNext();) {
Widget w = (Widget) iter.next();
grid.remove(w);
}
grid.removeRow(row);
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
long key = ((Long)entry.getKey()).longValue();
grid.setWidget((int)(key>>>32), (int)(key & 0xFFFF), (Widget)
entry.getValue());
}
}
private static Object myComputeKey(int row, int column) {
long r = ((long)row<<32) + column;
return new Long(r);
}
private static int getRowIndex(Widget w) {
Element td = DOM.getParent(w.getElement());
Element tr = DOM.getParent(td);
return DOM.getChildIndex(DOM.getParent(tr), tr);
}
private static int getColumnIndex(Widget w) {
Element td = DOM.getParent(w.getElement());
Element tr = DOM.getParent(td);
return DOM.getChildIndex(tr, td);
}
private static final String REF_ATTR_NAME = "ref";
private static int _widgetCount;
protected String computeKey(int row, int column) {
// return row + "-" + column;
Element tr = DOM.getChild(getBodyElement(), row);
Element td = DOM.getChild(tr, column);
String ref = DOM.getAttribute(td, REF_ATTR_NAME);
if(ref == null) {
ref = String.valueOf(++_widgetCount);
DOM.setAttribute(td, REF_ATTR_NAME, ref);
}
return ref;
}
ste...@gmail.com wrote:
> it seems that removeRow() is buggy.
> setWidget(row,col,w) will put widget to a map with key "row-col", when
> a row is remove before the last row, the keys in map will be invalid.
>
> here is codes to fix this bug. hope GWT can fix this bug in next
> release.
>
> public static void removeRow(FlexTable grid, int row) {
> Map map = new HashMap();
> for (Iterator iter = grid.iterator(); iter.hasNext();) {
> Widget w = (Widget) iter.next();
> int rowIndex = getRowIndex(w);
> if (rowIndex > row){
> map.put(myComputeKey(rowIndex-1, getColumnIndex(w)), w);
> }
> }
> for (Iterator iter = map.values().iterator(); iter.hasNext();) {
> Widget w = (Widget) iter.next();
> grid.remove(w);
> }
> grid.removeRow(row);
> for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
> Map.Entry entry = (Map.Entry) iter.next();
> long key = ((Long)entry.getKey()).longValue();
> grid.setWidget((int)(key>>>32), (int)(key & 0xFFFF), (Widget)
> entry.getValue());
int key = ((Integer)entry.getKey()).intValue();
grid.setWidget(key>>>16), key & 0xFFFF, (Widget)
entry.getValue());
> }
> }
>
> private static Object myComputeKey(int row, int column) {
> long r = ((long)row<<32) + column;
> return new Long(r);
int r = (row<<16) + column;
return new Integer(r);
FlexTable tries to remove previous widget before adding a new one in a
new cell.
So it searches for the old one.
Old one is seeked in a Map by key "$row-$col". So if you remove a row,
some widgets will
have a decremented row index. This however do not change in the Map
that. They still have
the old key that they were added this.
Check this code insite HTMLTabel ( inherited by FlexTable)
protected boolean internalClearCell(int row, int column, Element td) {
Widget widget = (Widget) widgetMap.get(computeKey(row, column));
if (widget != null) {
// If there is a widget, remove it.
removeWidget(row, column, widget);
return true;
} else {
// Otherwise, simply clear whatever text and/or HTML may be
there.
DOM.setInnerHTML(td, "");
return false;
}
}
Here is the solution :
class GTable extends FlexTable{
public void removeRow(int row){
int total = this.getRowCount();
int rowsBellow = total - row - 1;
Widget [][]toMove = new Widget[rowsBellow][];
//store old widgets
for (int i = row+1; i < total; i ++){
int rCols = this.getCellCount(i);
Widget []wRow = new Widget[rCols];
for (int j = 0; j < rCols; j++){
Widget w = this.getWidget(i, j);
if (w != null)
this.remove(w);
wRow[j] = w;
}
toMove[i-row-1] = wRow;
}
super.removeRow(row);
//restore old widgets
for (int i = row; i < total-1; i ++){
int rCols = this.getCellCount(i);
Widget []wRow = toMove[i-row];
for (int j = 0; j < rCols; j++){
Widget w = wRow[j];
if (w != null)
this.setWidget(i, j, w);
}
}
}
}
Enjoy..
Let me know if your suffering is over :) (really :) )
> class GTable extends FlexTable{
> public void removeRow(int row){
> int total = this.getRowCount();
> int rowsBellow = total - row - 1;
>
> Widget [][]toMove = new Widget[rowsBellow][];
Hi om.obosit I'm still suffering the problem; when i try to remove a
row i get a NegativeArraySizeException caused by getRowCount that
returns a 0 row instead of 2 (total rows i've in the table).
also still have the problem with the GTable fix:
ERROR] Uncaught exception escaped
java.lang.IndexOutOfBoundsException: Row 4 does not exist, row size is
4
at
com.google.gwt.user.client.ui.HTMLTable.checkRowBounds(HTMLTable.java:891)
at
com.google.gwt.user.client.ui.HTMLTable.checkCellBounds(HTMLTable.java:869)
at com.google.gwt.user.client.ui.HTMLTable.getText(HTMLTable.java:557)
at
ru.lanit.btp.rft.gui.client.TransferChannels.setClickedChannelFieldsFromTable(TransferChannels.java:242)
at
ru.lanit.btp.rft.gui.client.TransferChannels.showChannelForEdit(TransferChannels.java:202)
at
ru.lanit.btp.rft.gui.client.TransferChannels.access$8(TransferChannels.java:197)
at
ru.lanit.btp.rft.gui.client.TransferChannels$5.onClick(TransferChannels.java:184)
at
com.google.gwt.user.client.ui.ClickListenerCollection.fireClick(ClickListenerCollection.java:36)
at
com.google.gwt.user.client.ui.Hyperlink.onBrowserEvent(Hyperlink.java:120)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:950)
Thanx,
Polina
Iam facing the same problem with FlexTable. I see that if i remove a
row say "2" out of 10 rows and then try to access
flextable.getRow(2,0).. I see that the widget returned is "null". And
it also looses track of the last row(since it decreases the rowCount to
9)
Any solution?
public void baloniClearData(FlextTable grid){
for (int i=grid.getRowCount()-1; i>=0;i--){
grid.removeRow(i);
}
}
Table is heap in gwt. LIFO...