Announcement

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

    Saving/Retrieving AdvancedCriteria to/from MySQL database

    Hello,
    I have trouble wrapping my head around the following.

    Using the FilterBuilder I create an AdvancedCriteria object.

    I want to:
    1) save some string representation of this object in the database
    2) restore a AdvancedCriteria object from this string.

    Is there an easy way to do this? Because I got the feeling I am missing something obvious :-)

    Not really feeling to write a serializer/parser...

    BTW: I use SmartGWT Power.

    #2
    Use getJSObj() to get the underlying JavaScript Object. This can be serialized and deserialized using JSONEncoder.

    Comment


      #3
      Ah that idea makes sense, but this throws a JavascriptException using the Power nightly (and also an earlier Power nightly of two weeks ago):
      Code:
       
      (SC_SNAPSHOT-2011-03-02/PowerEdition Deployment 2011-03-02)
      example code:
      Code:
      AdvancedCriteria crit = new AdvancedCriteria();
      String criteriaJSON = "";
      JavaScriptObject jsObj = crit.getJsObj();
      JSONEncoder enc = new JSONEncoder();
      criteriaJSON = enc.encode(jsObj); //gives exception
      JavascriptException thrown:
      Code:
      10:18:26.037 [ERROR] [generatedcode] Uncaught exception escaped
      
      com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
          at com.google.gwt.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:214)
          at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:103)
          at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:101)
          at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:66)
          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:157)
          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:126)
          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.GeneratedMethodAccessor34.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:157)
          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:680)
      Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): self.encode is not a function
       fileName: http://127.0.0.1:8888
       lineNumber: 3
       stack: ([object Object])@http://127.0.0.1:8888:3
      @:0
      ([object GWTJavaObject],1179847,[object GWTJavaObject])@http://127.0.0.1:8888/generatedcode/hosted.html?generatedcode:56
      ([object Object],(void 0))@http://127.0.0.1:8888:1226
      ((function () {var param = {};var event = __gwt_makeJavaInvoke(1)(null, 2818167, param);__gwt_makeJavaInvoke(1)(selfJ, 1179847, event);var ret = __gwt_makeJavaInvoke(0)(event, 1441798);return !ret;}),[object Object],[object Object])@http://127.0.0.1:8888:71
      @:0
      (null,65642,(function () {var param = {};var event = __gwt_makeJavaInvoke(1)(null, 2818167, param);__gwt_makeJavaInvoke(1)(selfJ, 1179847, event);var ret = __gwt_makeJavaInvoke(0)(event, 1441798);return !ret;}),[object Object],[object Object])@http://127.0.0.1:8888/generatedcode/hosted.html?generatedcode:56
      ([object Object],(void 0))@http://127.0.0.1:8888:55
      ([object Object],(void 0))@http://127.0.0.1:8888:13
      isc_StatefulCanvas_handleActivate([object Object],(void 0))@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Foundation.js:319
      isc_StatefulCanvas_handleClick([object Object],(void 0))@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Foundation.js:321
      isc_c_EventHandler_bubbleEvent([object Object],"click")@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Core.js:1571
      isc_c_EventHandler_handleClick([object Object])@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Core.js:1419
      isc_c_EventHandler__handleMouseUp([object MouseEvent],(void 0))@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Core.js:1406
      isc_c_EventHandler_handleMouseUp([object MouseEvent])@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Core.js:1397
      isc_c_EventHandler_dispatch(isc_c_EventHandler_handleMouseUp,[object MouseEvent])@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Core.js:1634
      anonymous([object MouseEvent])@http://127.0.0.1:8888/generatedcode/sc/modules/ISC_Core.js:61
      
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
      ...
      Am I doing something wrong?

      Comment


        #4
        There was a bug in the JSONEncoder responsible for this. Please try the next nightly and let us know if you still hit issues with it.

        Comment

        Working...
        X