First, a small update:
Those who read my last post, here, know that I was planning to use MVP with gwt-dispatch.
Well, at the time, GWTP seemed like an overhead and it included a fork of gwt-dispatch anyway so I thought MVP with gwt-dispatch would be lightweight and straight forward.
But, it seems GWTP has a lot more punch to it.
First, it allows for nested presenters, which is good. Second, it’s dispatch mechanism is like gwt-dispatch on steroids. Third, a lot of the boiler plate code is generated for you, especially if you use the GWTP eclipse plugin. Plus, it has annotations for auto generated DTOs and the like.
So, eventually, we decided to go with GWTP.
Well, that decided, I set out to create the client side eclipse project.
I created a Maven enabled project. The pom.xml file included the GWT-maven-plugin.
The result was a nightmare. Every build took 3-5 minutes, even after setting the permutations to only build for FF.
I wanted to have a work process where I code in Java and, using the development mode, run\debug the Java code with the server BackEnd running and responding to client requests, and to be able to build in a few seconds if I was to keep my sanity.
Below is what I did.
1. Since it’s a maven project, it’s not a gwt project out of the box.
Mark it as a gwt project (right click -> properties -> Google -> Web Toolkit).
2. Run the project as a Web Application. You will be prompted where to deploy the WAR – select the snapshot folder on the target folder
3. Install tomcat on your machine and define it in eclipse. After you do that, go to the tomcat properties and under publishing, select ‘never publish automatically’.
You see, tomcat looks for the WAR file under the target folder, that’s why we did step 2. The thing is, that when you have tomcat publish automatically, it changes files in the target folder as part of the publish process, which, of course, triggers another publish process… you can imagine where this is going…
Setting to ‘never publish automatically’ does not mean you have to publish every time you make a code change – that is still synced.
4. Publish and start the server
5. Comment out the gwt-maven-plugin in the pom.xml file. We don’t need it in development, since we are using development mode to run\debug.
So, final setup for day-to-day development is start the server and publish, then run the project as a web application in development mode. Since both are up, client-server RPC calls will work as you expect and you can still debug your Java code.
Next post will describe how to use Action\Result objects (Command\Response in gwt-talk) to make RPC calls.
Newsflash – it is not as simple as you might think…
Until next time – happy coding!