Announcement

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

    TileGrid and ListGrid use same RPC DataSource?

    Hello everybody,

    I want to use a RPC datasource (extends GwtRpcDataSource) for a ListGrid and a TileGrid. In the executeFetch() method I set an array of Records in response.setData(records). The records are of the type ListGridRecord.
    If I open the TileGrid in the GUI I get a ClassCastException:
    Code:
    Uncaught JavaScript exception [java.lang.ClassCastException: de.dig.cms.gui.client.component.media.MediaTileRecord cannot be cast to com.smartgwt.client.widgets.tile.TileRecord
    [ERROR] 	at com.smartgwt.client.widgets.tile.TileRecord.getOrCreateRef(TileRecord.java:69)
    [ERROR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [ERROR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [ERROR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [ERROR] 	at java.lang.reflect.Method.invoke(Method.java:597)
    [ERROR] 	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    [ERROR] 	at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
    [ERROR] 	at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    [ERROR] 	at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    [ERROR] 	at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
    [ERROR] 	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
    [ERROR] 	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    [ERROR] 	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
    [ERROR] 	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
    [ERROR] 	at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
    [ERROR] 	at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
    [ERROR] 	at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
    [ERROR] 	at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)] in http://localhost:8080/org.apache.sling.launchpad.webapp-5-incubator/cms/hosted.html?cms, line 6
    If I use the type Record instead of ListGridRecord, I get an Exception in the Listgrid.
    If I use the type TileRecord, the ListGrid doesn't show anything.

    Any suggestions?

    Thanks

    #2
    Hi,

    You can use request.getComponentId () and Canvas.getById (id) methods to identify component which is requesting data.

    Either depending on component ID or depending on instanceof you can decide which type of records to return.

    Alius.

    Comment


      #3
      Thanks,

      that works.
      But wouldn't it be a nice, if the types were compatible with each other? Both have Record as superclass.

      Thorsten

      Comment


        #4
        Originally posted by Thorsten
        Thanks,

        that works.
        But wouldn't it be a nice, if the types were compatible with each other? Both have Record as superclass.

        Thorsten
        Try to return Record instead of TileRecord or ListGridRecord (haven't tried myself).

        Alius.

        Comment


          #5
          Thanks alius.

          As I mentioned in my first post:
          If I return an array Records[] with elements of type Record (new Record()), I get an exception in the ListGrid.
          So I think ListGrid requires new ListGridRecord()!?! Or did I something wrong?

          Another problem is, that the ListGrid and the TileGrid have both their own (different) ResultSets. Only because of that, I can differentiate in the executeFetch().
          If I make an Update only once executeUpdate() is called. Which type should I return in this case?
          I think in principle it would be better to use one ResultSet for both the ListGrid and the TileGrid.

          Comment


            #6
            I'm also interested in the best practice of using 1 DataSource which transforms data into Record with ListGrid/Form/TreeGrid etc.

            Also see this thread.

            Comment

            Working...
            X