Showing posts with label gwt. Show all posts
Showing posts with label gwt. Show all posts

Wednesday, April 7, 2010

A cool Vaadin application on Google App Engine

Vaadin, as we all know is a rapidly growing GWT based Java Web Framework. The coolest feature of Vaadin is that there is no client/server concept as it is in GWT. The developer can freely code anything "anywhere" and Vaadin will handle all the client/server related stuffs. 

One of our existing in-house production application is built using GWT and causing lot of difficulties for developers in terms of understanding the model and designing the proper application. So to retain all the GWT features and offload the additional burdens we (as such I) have decided to move to the Vaadin and redesign the existing application.

To convince the technical and management team and for demonstration purpose I developed a small application in Vaadin and uploaded it to the Google Application Engine (click here) so that others can also get the idea and at the same time I can load test the application and get all the execution details from the App Engine dashboard.  

The application contains a simple functionality where in which the user can design her custom entry forms, enter/save form data and finally view the saved data in a table. The application was built in few hours only so it doesn't have "next big ground breaking idea" or the nice GUI but Vaadin provides fairly nice UI which can work for any application to start with.

To speed up the development I extended the basic Form functionality to a Generic Form so that UI Forms can be created not only from Java Beans but from java.util.Map also. The reason to choose this is because some of our applications are purely data centric where in which numbers of UI forms are presented to users; however the fields in every form can very even after application deployment so to reduce the repetitive development effort I have taken the model where in which forms not only can be generated at runtime but can behave line a normal pre-coded form in most of the cases.

There are still many points to resolve before we finally switch over to Vaadin as our web application development framework but with the growing popularity of the framework and new initiative like Vaadin Directory acceptance would not be much difficult.

Vaadin demo application url: http://vaadincoolapp.appspot.com/

Saturday, February 20, 2010

GWT client with REST

This article explains a small prototype i developed for a friend to show how REST services can be used can be used from the client code and avoid additional RPC call. The demo explains only two fundamental class structures to access the remote service.

RequestBuilder
GWT client API is having an HTTP request builder class which helps the application to make remote connection through HTTP request and supported methods (GET, POST).

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, urlAddress);
builder.sendRequest("", new RequestCallback() {
  
  public void onResponseReceived(Request request, Response response) {
     //use response.getText() to get the resulting text from the service
  }


  public void onError(Request request, Throwable exception) {
     // exception handling
  }
});

XmlParser
GWT client API also provides XML parsing capabilities but to use that XML.gwt.xml has to be included in the modules file.

The following code can parse the XML text and prepare complex node list which can be traversed to access the attributes and node values.

    Document doc = XMLParser.parse(response.getText());

Once Document instance is generated program can start traversal from the root node or can search for the particular nodes based on the name.

    NodeList nodeList = doc.getChildNodes(); // to start from root node
    NodeList nodeList = doc.getElementsByTagName(nodeName);  // to start from selected node

Full source code with example services is available here.