Thursday 16 May 2013

Must for GWT Developers-- All That GWT Developer must know to develop large GWT Web Application

Must for GWT Developers


Use Java for creating Ajax applications

No need to worry about browser dependencies, it works in all the browsers.

debugging UI is easy

Important modules in GWT?

GWT Compiler
JRE Emulation library
Hosted Mode ( Run as java)
Web Mode ( Run as JavaScript)

What is GWT Compiler?
GWT Compiler used to convert the client side Java code to Javascript at the time of building the source files.

GWT - Java Emulation library?
    
Google Web Toolkit includes a library that emulates a subset of the Java run-time library. The list below shows the set of JRE packages, types and methods that GWT can translate automatically. Note that in some cases, only a subset of methods is supported for a given type.

    java.lang
    java.lang.annotation
    java.math
    java.io
    java.sql
    java.util
    java.util.logging


Bootstrap process:

HTML
  |
nocache.js ( Bootstrap javascript file )
  |
  |->( Loads the browser specific files)
  |
module.xml ( *.gwt.xml )
  |
  |->( which loads the entry point class )
  |
onModuleLoad() method
  |
  |
  |
Loads the application

HTML
          -- > .nocache.js (bootstrap JavaScript file)
          -- > Which loads the browser specific files (Permutation javascript file)
Module.xml
         -- > Basic inherits (required modules)
         -- >Entry point class (onModuleLoad () method)
         -- > cross site linker (useful for code splitting)

Organize Gwt Projects


GWT Linkers: 

The primary linker (there also are secondary linkers, but they're not involved here) is responsible for creating the *.js or *.html files that host the compiled JS code, and of course how to bootstrap/load them into the browser.

             IFrameLinker – Default
                XSLinker – For cross site support
                SingleScriptLinker
                <add-linker name=”XS”>

UIBinder - useful for designing the GUI using XML format ( you can mix HTML and GWT Widgets)


How to create custom widgets in GWT?

Create a class that should extends Composite class of GWT.
Inside the constructor you can write you logic to create a widget and call the initWidget method().

Then you can use this class in anywhere in the application and add this widget in any panels.


What is AsyncDataProvider in GWT cell widgets? 

When you want to display dynamic data or a range of data, not just a static list, then we should use AsyncDataProvider.


Example : http://www.mytechtip.com/2010/11/gwt-celltable-example-using_8168.html

What is the use of ValueUpdater vs FieldUpdater in Cell Widgets?

GWT ClientBundle:

In GWT we can use ClientBundle to load all the images and CSS files in one single file and use it anywhere in the application. It provides flexible way to get the resources.

1. It creates a single image from the collection of images at compile time to reduce the image size.
2. Enable more aggressive caching headers for program resources. It will go to server for every-time to get the images.
3.Eliminate mismatches between physical file names and constants in Java code by performing consistency checks during the compile

Server side communication:

-- > Using GWT RPC

-- > Using RequestBuilder

          To use RequestBuilder we need to inherit HTTP Module in module.xml file
          <inherits name="com.google.gwt.http.HTTP"/>


--> Using Command Pattern (GWTP Dispatcher)

→ Request Factory : recommended

GWT Serialization:

                -- >Using GWT IsSerializable OR Java Serializable



What is Entry-point class in GWT and how to configure this?

History Management- BookMarking URL.How GWT Navigation works?

          In GWT we can handle page navigation using couple of ways.
          1. Using History tokens
          2. Clearing the content panel and load the new page in the content panel.
          3. Using Activities, Activity Manager, and Places concepts (Recommended)
          4. GWT P Provides annotation for history mangement

https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces



GWT RPC vs GWT RequestBuilder ( for server side communication )

          1. When we use GWT RPC we dont need to handle Serialization / Deserialization of the request.
          2. When we use RequestBuilder we need to handle Serialization / Deserialization of the request/response.

http://milansoftwareengg.blogspot.in/2013/05/gwt-request-factory-vs-rpc.html


What is the use of UIBInder in GWT and why we should use UIBinder? 

http://milansoftwareengg.blogspot.in/2013/05/ui-binder-gwt.html

How can you test a GWT application?

What is deferred binding in GWT?

Describe what a GWT generator does
    Refer the following URL
    http://stackoverflow.com/questions/3298317/what-is-the-use-gwt-generator 


What are some benefits of using CssResource, ImageResource, TextResource, etc

How does GWT app work? (compiling to JavaScript, cross-browser support, bootstrapping script, etc.)


When would you NOT use GWT? (rather general and open-ended question, but it demonstrates if developer is really into this technology)
    Follow-up question: What GWT alternatives would you consider?


Describe server-side development with GWT.


Serialization and Un-serialization. What is required of a user defined class for it to be serializable?


       All we need to do is create a class which implements GWT IsSerializable or Java Serializable interface.



IsSerializable Vs Serializable:

Both are acceptable in GWT to make a class serializable.

When you use Normal java Serializable you need to take care all the serialized classes are available in the Serialization policy file or not.

But when you use GWT IsSerializable, you don't need to worry about Serialization policy file.

So, if your class is only used by GWT application, better we can go for GWT IsSerializable.

If your model class is used by more than one Application then better use Java Serializable.

Event handling. Describe how an event bus is used and implemented.(Recommended)    
Create a Classs that extends GWTEvent
        Define a new handler and marker interface for the event class.
        Register the event using EventBus where you implement interface( the one written inside the event class)
        implement the interface method and call the event fire method



Architecture
1. Using GWTP (Recommended)
http://code.google.com/p/gwt-platform/

2. MVP Architecture(Recommended)


3. Using GIN Dependency injector in GWT

What are some advantages for the Model-View-Presenter pattern?

What 3d party libraries have used with GWT? Which libraries would you recommend? Why?        GUICE - for Server side dependency injection
        GIN - for client side dependency injection
        GWTP - Model - View - Presenter framework

What does make MVP better fit for GWT than general MVC? 

There are various design patterns to choose from; Presentation-abstraction-control, Model-view-controller, Model-view-presenter, etc... And while each pattern has its benefits, we have found that a Model-view-presenter (MVP) architecture works best when developing GWT apps for two main reasons. First the MVP model, much like other design patterns, decouples development in a way that allows multiple developers to work simultaneously. Secondly, this model allows us to minimize our use of GWTTestCase, which relies on the presence of a browser, and, for the bulk of our code, write lightweight (and fast) JRE tests (which don't require a browser).

Performance(Recommended)
Code Splitting is easy

Fragment Merging


Using Spring Roo with GWT (Recommended)

Spring roo auto generates 
1. Server Component : Server Entity, Hibernate Configuration
2. Client Component :  Injecting dependency using gin, RequestFactory, Client Proxy, UI, Activities, Place

Create your own entry point class and Reuse Code Related to Gin Injector, History Management, basic architecture.

Spring roo auto creates and updates domain model and request factory code.

For more information about how to quick set up project architecture using gwt and spring roo, you can freely contact me.

(To be Updated)

No comments:

Post a Comment