Announcement

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

    Configure restful datasource with XML?

    Is it possible to define the fields of a restFull datasource
    using the standard SmartGWT XML files?

    #2
    Sorry, there are several possible interpretations of this question, can you be more specific?

    Comment


      #3
      With server-side datasources, you can specify the information contained in the datasource using .xml files. The datasource is automatically created with the fields defined in the .xml file.

      I need a restful datasource which is client-side. Will SmartGWT generate the code necessary to generate a datasource from XML when the datasource runs on the client side?

      Comment


        #4
        Yes, this can be done - load the DataSource normally using the DataSourceLoader servlet, and use _constructor="RestDataSource" on the <DataSource> tag to cause a RestDataSource to be created in the browser. Any given method call on RestDataSource translates to a same-named property in XML by the Java Beans convention (setBlah("value") -> blah="value").

        However the question is - what for? Just trying to make sure you're not doing unnecessary work, it's hard to image why you would do this.

        Comment


          #5
          We are developing a restful service API that will need to service both
          a SmartGWT application and third party applications.

          We want to leverage the SmartGWT client-side RestDataSource
          code to ease transfer of objects.

          It seemed like a lot of unecessary work to create the datasource
          and then write all of the code to define all of the fields of the
          datasource.

          Comment


            #6
            Hmm, you sound like you may be confused..

            If you want third-party applications to have access to your DataSource operations, this is automatic, no effort required - see the RestHandler discussion in the Server Framework chapter.

            If you want to access pre-existing Rest services hosted elsewhere within your company, there is no need to *both* create a server-side DataSource and client-side DataSource. Just create the client-side DataSource.

            Comment


              #7
              I guess a little confused....

              Are there examples of using RestHandler?

              If I use the RestDataSource + RestHandler do I get the
              nice integration of filtering, sorting, etc?

              If I bind a ListGrid to a RestDataSource connected to
              a RestHandler, can I use the sorting facilities in ListGrid?

              This would be great in that we could have one service
              that could function as the SmartGWT gui backend and
              also allow automated connection by third parties for
              data mining.....

              Comment


                #8
                you should just read RestHandler docs - it's basically a servlet that implements a REST API from your ds definitions. pretty simple

                Comment


                  #9
                  Yes, it would work to create a RestDataSource to talk to the RestHandler. Don't do this. Continue using DataSources based on .ds.xml files exactly as described in the QuickStart Guide and other materials.

                  The purpose of the RestHandler is for third party technology to talk to the DataSources you've defined via .ds.xml files, using the same XML or JS *message format* as the RestDataSource, but not using the RestDataSource class itself (since we're talking about third-party non-SmartGWT technology).

                  In a nutshell, just by using the system as described in the QuickStart Guide, you are already done with what you wanted to do (provide a REST interface for third parties).

                  Comment


                    #10
                    Ok. I think I am beginning to understand....

                    RestHandler exposes existing SmartGWT Datasources to third
                    party clients.

                    Is there example code using the RestHandler?

                    Do you need to configure a RestHandler for each existing datasource
                    individually, or are all Datasources exposed?

                    Comment


                      #11
                      All DataSources are exposed.

                      There's no example code (it wouldn't be a SmartGWT example) but there are example messages / URLs, since the RestDataSource class explains the protocol. For a simple test, put together a URL to the RestHandler servlet with appropriate parameters and just paste it into the address bar of an ordinary web browser.

                      Comment

                      Working...
                      X