SmartGWT RestDataSource

2019-02-27 00:53发布

I'm using SmartGWT/SmartClient LGPL, I can't use the Pro, due to project ties.

I would like to create a RestDataSource from a jdbc connection, to be exposed from the server to the SmartGWT client.

How could it be done?

Any help is greatly appreciated.

标签: smartgwt
2条回答
Juvenile、少年°
2楼-- · 2019-02-27 01:31

Here's a general outline of what you could do if not using GWT and using PHP. Would be similar idea with java.

Define your DataSource in your file

    isc.RestDataSource.create({
     ID: "yourDS"
    ,fields: [
         {name: "id", hidden: true, primaryKey: true}
        ,{name: "name", title: "field1"}
     ]
    ,dataFormat: "json"
    ,dataURL: "dmi/yourDMI.php"
})

Then define yourDMI.php controller file. It should have checks for all the operation types, fetch, add, delete, update

    if (isset($_GET['_operationType']) && strcmp($_GET['_operationType'], "fetch") == 0) {
         // do something..  return JSON response
    }

    if (isset($_GET['_operationType']) && strcmp($_GET['_operationType'], "add") == 0) {
         // do something..  return JSON response
    }

    if (isset($_GET['_operationType']) && strcmp($_GET['_operationType'], "delete") == 0) {
         // do something..  return JSON response
    }

    if (isset($_GET['_operationType']) && strcmp($_GET['_operationType'], "update") == 0) {
         // do something..  return JSON response
    }
查看更多
The star\"
3楼-- · 2019-02-27 01:42

Have you had a look at the source code for the RestDataSource Edit & Save example from the Showcase? It's a good starting point.

If you want REST on the server I'd recommend Restlet talking to a JDBC backend. You could take the example above and wire it up to your Restlets instead of the XML.

查看更多
登录 后发表回答