Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    CanvasItem.storeValue() only firing ChangedEvent once

    I may have found a bug with CanvasItem's storeValue() method. I have a ChangedHandler set up on the CanvasItem, and the ChangedEvent is only getting fired the first time I call storeValue() in the CanvasItem. If I make further changes to the value(s) in the CanvasItem, storeValue() keeps getting called, but the ChangedHandler doesn't see any more events.

    I've attached a standalone test case to show this behavior, and added a SC.logWarn() each time the event is fired.

    When the ChangedEvent is fired, the listener in this this test case also tries to print out the number of records in the ListGrid inside the CanvasItem. This RecordList is the value passed to storeValue(). I'm trying to pull this RecordList from the ChangedEvent, and I'm not getting the results I would expect. I'm not sure if this could be related to the behavior of storeValue() in the first issue I described.

    I'm using the 8-25-11 SmartGwt 3.x nightly build, tested in Firefox and Chrome.

    Thanks,
    Reed
    Attached Files

    #2
    It looks like you are re-registering the changedHandler every time the event fires? This could cause the problem, and there doesn't seem to be a reason to do it.

    Comment


      #3
      Oops, I hadn't meant to leave that in there, but I think it was originally just there to try to solve this problem. I removed that line and I'm still seeing the same behavior with the event only firing on the first change.

      Comment


        #4
        Ah OK, this is actually a usage problem. The result of getRecordList() is the same every time, and it should be, because a single RecordList object being changed by having records added or removed, but it is the same RecordList instance every time. It's not clear what the ultimate use case is, but one way around this would be to use an Array of Records as the stored value rather than the RecordList object.

        Comment


          #5
          Thanks, understood. I tried changing the storeValue() call to:

          storeValue(myGrid.getRecords())
          and
          storeValue(myGrid.getRecordList().toArray())

          and I get a JavaScript error each time I finish adding a record to the grid and storeValue is called. I can print out the records returned by getRecords(), and they look fine. Is this incorrect usage of storeValue()?


          com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
          at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
          at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:67)
          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.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
          at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
          at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
          at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
          at java.lang.Thread.run(Thread.java:619)
          Caused by: com.google.gwt.core.client.JavaScriptException: (null): null
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
          at com.smartgwt.client.widgets.form.fields.CanvasItem.storeValue(CanvasItem.java)
          at com.tempusnova.canvasitemtest.client.CanvasItemStoreValueTest$1.onRowEditorExit(CanvasItemStoreValueTest.java:47)
          at com.smartgwt.client.widgets.grid.events.RowEditorExitEvent.dispatch(RowEditorExitEvent.java:99)
          at com.smartgwt.client.widgets.grid.events.RowEditorExitEvent.dispatch(RowEditorExitEvent.java:1)
          at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
          at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
          at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
          at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
          at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:67)
          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.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
          at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
          at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
          at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
          at java.lang.Thread.run(Thread.java:619)

          Comment


            #6
            It's unclear where this is coming from. Can you capture a stack trace from the SmartGWT Developer Console in *compiled mode*? See FAQ for details if you haven't done this before.

            Comment


              #7
              I ran this last night in compiled mode with the Developer Console, and didn't actually get any errors or stack trace in the console, no logs above INFO level. I ended up finding a way to do what I needed without getting the javascript error.
              Instead of trying to pass an array of records by calling storeValue(grid.getRecords()), I create a RecordList with the current records just before calling storeValue().

              RecordList records = new RecordList(grid.getRecords());
              then call storeValue(records).

              Comment


                #8
                Thanks Reed, you found it!

                That's what I needed for my MultipleItem: http://forums.smartclient.com/showpo...9&postcount=13

                Isomorphic, I still don't understand why we can't pass anything to storeValue(). I would like to pass a List<String> or at least a String[]. But it seems storeValue() crashes with those types.
                Last edited by ferranmc; 3 Jan 2012, 09:09.

                Comment


                  #9
                  As mentioned in the related thread, we're not sure what problem ferranmc is trying to solve or why he thinks there's an issue. We've asked for clarification.

                  Comment


                    #10
                    Originally posted by Isomorphic
                    As mentioned in the related thread, we're not sure what problem ferranmc is trying to solve or why he thinks there's an issue. We've asked for clarification.
                    I will reply about that in the other thread.

                    In this thread, I would like to know why we can't call:

                    Code:
                    storeValue( myGrid.getRecordList().toArray() )
                    but we must do this:

                    Code:
                    storeValue( new RecordList(grid.getRecords()) )
                    In other words, why we should pass a RecordList to storeValue and we can't pass a Record[] or a List<Record> or let's say a Map<String,Date>.

                    Comment


                      #11
                      Both should work. We need to see a test case where we can reproduce the reported error, or at the least the stack trace we asked for.

                      Comment

                      Working...
                      X