SmartGWT RestDataSource

六眼飞鱼酱① 提交于 2019-12-01 22:52:56

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.

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
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!