Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Java framework works best with Google Web Toolkit?

Tags:

java

servlets

gwt

GWT is the main reason I'm moving into java for web development. Which java framework will work best with it, while also maximizing code reuse for mundane tasks like form validation, database access, pagination, etc?

Thanks.

like image 870
Ali Avatar asked Apr 02 '09 20:04

Ali


People also ask

What Framework does Google use with Java?

GWT, or the Google Web Toolkit, is a web framework created by Google. You can use it to quickly build Java apps for the web, as it allows you to write client-side Java code and deploy it as JavaScript for the browser. GWT (pronounced “gwit”) is a stable and well-maintained Java framework.

Which Framework is used for web development in Java?

Struts is an open-source Java EE framework used for creating enterprise-level Java web applications. Development is much easier with Struts since it uses the MVC pattern and convention over configuration. The MVC pattern also enables clean designs that are easy to implement.


2 Answers

Spring is the obvious one you should be using. GWT has its own RPC controller framework so I can't really think what you would need a Web application framework (like JSF) for.

JPA is a reasonable choice on several fronts but it has problems too.

For one thing, its potentially an issue sending JPA objects to the client. GWT (up to 1.5 at least) enforces a pretty strict directory structure so you'd have to put your entities under the GWT source tree. That aside, serializing (JSON usually) JPA entities to and from the client is potentially problematic.

JPA entities are fairly rigid objects that map almost one-to-one to your tables. That doesn't tend to be how you use data in a presentation layer however. Direct SQL will allow you to pick and choose which data you do and don't want, tailored specifically for that page. So JPA entities will typically have lots of fields you're not interested in and shouldn't serialize (particularly collections of one-to-many relationships).

Now that aspect of SQL--tailoring it to the page--is often cited as an advantage of entities: your code doesn't end up littered with one-use value objects. Thing is, you still end up with the same thing in gWT+JPA but instead of being in the persistence layer or the business layer you end up with them in the presentation layer. Now you might call that an advantage. I call it six of one, half a dozen of the other.

I actually think Ibatis is a far better fit to the GWT application model than JPA for the reason that you are using direct SQL, objects tailored for your purpose and those objects can be used all the way from the database to the client. Now this concept may horrify the layering zealots that are quite common in Java land but remember layering is a means to an end not an end in itself. Use it if it helps you. Don't if it doesn't.

But Spring is the absolute must in this stack.

I'll also refer you to Why isn’t Google Web Toolkit more popular? and Using an ORM or plain SQL?.

like image 77
cletus Avatar answered Oct 08 '22 06:10

cletus


If you are developing more application like sites instead of page based sites, I would recommend having a look at the Open Source framework Vaadin. This is server-driven framework which uses GWT on the client side for rendering the frontend, but also automatically handles and keeps sensitive business logic on the server side. This adds some security and you don't have to worry about client<->server traffic (if you don't want to), but can focus on implementing the server side logic in whatever way you prefer. Biggest plus is that you really don't have to code anything else that Java. It is also fairly easy to implement own new GWT components to the framework.

Disclaimer: Yes, I work for IT Mill developing Vaadin, but having a look hasn't hurt anyone yet, has it?

like image 32
Jonas Granvik Avatar answered Oct 08 '22 06:10

Jonas Granvik