user63904
user63904

Reputation:

An example of a Google Web Toolkit (GWT) Create Read Update and Delete (CRUD) Application

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

Upvotes: 3

Views: 12355

Answers (4)

kaefert
kaefert

Reputation: 309

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.

Upvotes: 0

sap
sap

Reputation: 1141

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

Upvotes: 3

Low Flying Pelican
Low Flying Pelican

Reputation: 6054

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/

Upvotes: 0

Carlos Tasada
Carlos Tasada

Reputation: 4444

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?

Upvotes: 1

Related Questions