On Thursday, November 29, 2012 1:54:38 PM UTC+1, Piotr Kopeć wrote:
>
> Hi All
> As workaround for editing NULL values in CellTable i've extended Column
>

Why? That's the job of cells, not columns. If a cell doesn't allow editing 
a 'null', then extend/fork that cell instead; or give it a non-null value. 
This is exactly what the workarounds at 
https://code.google.com/p/google-web-toolkit/issues/detail?id=5791 are 
doing.
 

> All works nice till use of SingleSelectionModel
> With selection model editing null values goes random, some values can be 
> edited, some not, after few tries selection model stops responding
> Related exception stack trace below:
>
> [ERROR] com.google.gwt.core.client.JavaScriptException: (TypeError) 
>> @com.google.gwt.dom.client.Element::focus()([]): this.focus is not a 
>> function
>> [ERROR]     at 
>> com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:570)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:298)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
>> [ERROR]     at com.google.gwt.dom.client.Element$.focus$(Element.java)
>> [ERROR]     at 
>> com.google.gwt.cell.client.EditTextCell.resetFocus(EditTextCell.java:240)
>> [ERROR]     at 
>> com.google.gwt.cell.client.EditTextCell.resetFocus(EditTextCell.java:1)
>>
>  

> [ERROR]     at 
>> com.google.gwt.user.cellview.client.AbstractCellTable.resetFocusOnCellImpl(AbstractCellTable.java:2575)
>> [ERROR]     at 
>> com.google.gwt.user.cellview.client.AbstractCellTable.resetFocusOnCell(AbstractCellTable.java:2193)
>> [ERROR]     at 
>> com.google.gwt.user.cellview.client.AbstractHasData$View$1.execute(AbstractHasData.java:290)
>> [ERROR]     at 
>> com.google.gwt.user.cellview.client.CellBasedWidgetImpl.resetFocus(CellBasedWidgetImpl.java:102)
>> [ERROR]     at 
>> com.google.gwt.user.cellview.client.AbstractHasData$View.resetFocus(AbstractHasData.java:287)
>> [ERROR]     at 
>> com.google.gwt.user.cellview.client.HasDataPresenter.resolvePendingState(HasDataPresenter.java:1374)
>> [ERROR]     at 
>> com.google.gwt.user.cellview.client.HasDataPresenter.access$3(HasDataPresenter.java:1062)
>> [ERROR]     at 
>> com.google.gwt.user.cellview.client.HasDataPresenter$2.execute(HasDataPresenter.java:984)
>> [ERROR]     at 
>> com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
>> [ERROR]     at 
>> com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:228)
>> [ERROR]     at 
>> com.google.gwt.core.client.impl.SchedulerImpl.flushFinallyCommands(SchedulerImpl.java:327)
>> [ERROR]     at com.google.gwt.core.client.impl.Impl.exit(Impl.java:266)
>> [ERROR]     at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:257)
>> [ERROR]     at sun.reflect.GeneratedMethodAccessor286.invoke(Unknown 
>> Source)
>> [ERROR]     at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> [ERROR]     at java.lang.reflect.Method.invoke(Method.java:601)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
>> [ERROR]     at 
>> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
>> [ERROR]     at java.lang.Thread.run(Thread.java:722)
>>
>
> Example class for reproducing exception below:
>
>> public class GwtBugTest0 {
>>
>>     // Entity
>>     class Man {
>>         String name;
>>         Date birth;
>>     }
>>
>>     // column that renders [NONE] for null and is updater, also gives 
>> initial value for updater
>>     abstract class NoneColumn<T, V> extends Column<T, V> implements 
>> FieldUpdater<T, V> {
>>         V def;
>>
>>         public NoneColumn(Cell<V> cell, V def) {
>>             super(cell);
>>             this.def = def;
>>             setFieldUpdater(this);
>>         }
>>
>>         @Override
>>         public V getValue(T object) {
>>             V ret = getRawValue(object);
>>             return ret == null ? def : ret;
>>         }
>>
>>         @Override
>>         public void render(Context context, T object, SafeHtmlBuilder sb) 
>> {
>>             if (getRawValue(object) == null)
>>                 sb.appendHtmlConstant("[NONE]");
>>             else
>>                 super.render(context, object, sb);
>>         }
>>
>
Your problem is that you're not calling the cell's render() when the value 
is null (in this case, getValue() is not called so your default value is 
not really needed), so when the CellTable tries to set the focus back to 
the cell by calling the Column's Cell's resetFocus, the Cell (an 
EditTextCell here) doesn't find back its element (because it looks at 
something that it didn't generate) and ends up calling focus() on the wrong 
object.

Remove that render() override, and instead move that code into your own 
cell. Either extend EditTextCell or wrap it in your own cell, and handle 
resetFocus accordingly. It might be easier to fork and patch EditTextcell 
though (and contribute the patch back for inclusion in GWT proper)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/9xolVUnMWPAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to