问题
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
回答1:
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?
回答2:
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:
in GreentingService.java do following:
public interface GreentingServiceextends RemoteService { ArrayList getEverything(); }
in GreentingServiceSync.java do following:
public interface GreentingService { void getEverything(AsyncCallback callback); }
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 } }
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
回答3:
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/
回答4:
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.
来源:https://stackoverflow.com/questions/4064419/an-example-of-a-google-web-toolkit-gwt-create-read-update-and-delete-crud-ap