Google Web Toolkit (GWT) 创建、读取、更新和删除 (CRUD) 应用程序的示例

发布于 2024-09-30 04:22:45 字数 107 浏览 2 评论 0原文

你好
有谁知道任何基于 Google Web Take (GWT) 的创建、读取、更新和删除应用程序的示例。
即,使用 GWT 来操作和显示数据库内容的应用程序。

谢谢

Hello
Does anybody know of any examples of a Google Web Took (GWT) - based Create Read Update and Delete application.
That is, an application which uses the GWT to manipulate and display the contents of a database.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

盛夏已如深秋| 2024-10-07 04:22:45

网上这样的例子并不多。
但这就是我通常这样做的方式:

假设您想从数据库中获取某个表的所有内容:

  1. 在 GreentingService.java 中执行以下操作:

    公共接口 GreentingServiceextends RemoteService
    {
    ArrayList getEverything();
    }

  2. 在 GreentingServiceSync.java 中执行以下操作:

    公共接口GreentingService
    {
    void getEverything(AsyncCallback 回调);
    }

  3. 最后在 GreentingServiceImpl 中执行以下操作:

     公共类 GreentingServiceIMPL 扩展 RemoteSericeServlet 实现 GreentingService
       {
         公共ArrayList<字符串>获取所有内容()
         {
            字符串查询=“选择*来自...”;
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            连接 conn=DriverManager.getConnection(url,用户,密码);
            语句 stmt = conn.createStatement();
            //从这里的数据库中获取内容并以数组列表的形式重新调整
            }
         }
    
  4. 这是您调用此方法并使用数据的方式:
    公共 Someclass 实现 EntryPoint
    {
    公共无效 onModuleload()
    {
    SQLRunnerAsync sql = (SQLRunnerAsync) GWT.create(SQLRunner.class);
    异步回调>回调 = new AsyncCallback>(){

    <预><代码> @Override
    公共无效onFailure(Throwable捕获){
    //什么都不做

    }

    @覆盖
    公共无效onSuccess(ArrayList结果){

    for(int i = 0; i < result.size(); i++)
    {

    }
    }};
    sql.getEverything(回调);

    ............
    }//onModulelOad
    }//class

以下是一个很棒的教程:
http: //altair.cs.oswego.edu/~tenberge/tenbergen.org/misc/DB-Access-in-GWT-The-Missing-Tutorial.pdf

There are not too many such examples online.
But this is how I usually do it:

Lets assume that you want to get all the contents of a certain table from the database:

  1. in GreentingService.java do following:

    public interface GreentingServiceextends RemoteService
    {
    ArrayList getEverything();
    }

  2. in GreentingServiceSync.java do following:

    public interface GreentingService
    {
    void getEverything(AsyncCallback callback);
    }

  3. finally in GreentingServiceImpl do following:

       public class GreentingServiceIMPL extends RemoteSericeServlet implments GreentingService
       {
         public ArrayList<String> getEverything()
         {
            String query="Select * from....";
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection conn=DriverManager.getConnection(url,user,password);
            Statement stmt = conn.createStatement();
            //get stuff out of daatabase here and retun as an arraylist
            }
         }
    
  4. this is how you will call this method and use the data:
    public Someclass implements EntryPoint
    {
    public void onModuleload()
    {
    SQLRunnerAsync sql = (SQLRunnerAsync) GWT.create(SQLRunner.class);
    AsyncCallback> callback = new AsyncCallback>(){

        @Override
        public void onFailure(Throwable caught) {
            //do nothing
    
        }
    
        @Override
        public void onSuccess(ArrayList<String> result) {
    
            for(int i = 0; i < result.size(); i++)
                             {
    
    
            }
        }};
        sql.getEverything(callback);
    

    ...............
    }//onModulelOad
    }//class

Following is a great tutorial:
http://altair.cs.oswego.edu/~tenberge/tenbergen.org/misc/DB-Access-in-GWT-The-Missing-Tutorial.pdf

简单气质女生网名 2024-10-07 04:22:45

GWT 是一种客户端技术,因此基本上只为您提供 UI。任何 CRUD 过程都将发生在服务器端,这可以是任何 J2EE 代码。

无论如何,您可以查看 StockWatcher 示例,它为您提供了解决您的问题的好方法(您需要实现服务器端存储)

另请参阅 RequestFactory 文档

它对您有帮助吗?

GWT is a client side technology, so basically gives you only the UI. Any CRUD process would happen in the server side, which could be any J2EE code.

Anyway you can take a look to the StockWatcher Example which gives you a good approach to your question (you need to implement the server side storage)

Also take a look to the RequestFactory documentation

Does it help you?

梦回梦里 2024-10-07 04:22:45

这是一个骨架 CRUD 应用程序,这对于寻找同一问题答案的人来说会很有帮助

http:// code.google.com/p/gwtcrudapp/

This is a skeleton CRUD application, I this would be helpful for someone looking answer for the same question

http://code.google.com/p/gwtcrudapp/

无所谓啦 2024-10-07 04:22:45

这是一个基于 Web 的 CRUD 应用程序,是我在过去几年中为我的雇主编写的,现在已获得开源许可:

https://github.com/fhcampuswien/atom

前端使用GWT,后端使用Hibernate来持久化数据。数据结构只需要在一个中心位置(DomainObject 类)定义,因为 GUI 和后端都是以不依赖于数据结构的通用方式编写的。

如果有人有时间看一下,我很乐意听到评论或回答有关它的问题。

This is a web-based CRUD-Application that I've wrote for my employer over the last few years and now got permission to open-source it:

https://github.com/fhcampuswien/atom

It uses GWT for the front-end and Hibernate to persist the data in the backend. The data-structure only needs to be defined in one central place (the DomainObject classes), since both GUI and backend are written in a generic way that is not dependent on the data-structure.

I'd love to hear comments or answer questions about it if anybody finds the time to take a look.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文