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.
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.
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.
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?.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With