Ajax + Google = GWT

    Life Story (Foreword)

    A year ago, I had to start developing a UI for javascript web service. Over time, the UI has grown into a full-fledged thin client with a rather dynamic interface and rather big business logic. How did this javascript start to annoy me.

    Basically, 3 problems stood out
    1) the lack of inheritance and encapsulation. This seriously affected business logic. Of course there is Prototype and many different other frameworks to solve this problem, but after Java it all seemed far-fetched.
    2) the inability to create complex UI elements. I wanted to take out the repeating pieces of the UI into separate controls and use them, simply redefining some functionality.
    3) multibrowser. Even if you write everything under firefox, this does not always work in IE. The differences in XML parsing and the default values ​​of padding and marging styles were especially pleasing.

    In my opinion, the first two problems were caused by the lack of OOP. Clear and intuitive. The solution was straightforward: write a Java translator in JavaScript (JS). From a syntax point of view, Java is much stricter than JS, and so translation seemed a pretty solvable task. After further research, I was surprised and pleased by the fact that Google just took and solved all my problems ...

    Google Web Toolkit (GWT).

    Everything is very simple - we write an application in Java using standard sets of utilities and classes of Java 1.4, ready-made controls for the UI and a set of base classes from Google. There are restrictions there, but not too strong. Very close to a regular GUI application.
    Then all this is compiled by the GWT compiler and at the output we get an html file with js code. We get 6 different options: default, opera, safari, gecko, gecko1.8, ie6. Nothing extra. For each browser, only its own version of the code is loaded.

    From the point of view of the Java developer (and not only) GWT supports such useful things
    1) Java compiler in JavaScript
    2) debug.
    3) multibrowser.
    4) the ability to write modules.
    5) a wide range of widgets, panels and controls.
    6) RPC
    7) JUnit
    8) internationalization / Resource banding.
    9) JavaScript Native Interface - Inserts in pure javascript. The ability to pull from Java javascript and vice versa.
    10) JSON and much more.

    On GWT (or its prototypes) Google Mail, Google Maps, Google Base were written

    Who is GWT for?

    I think that this framework will be mainly useful to Java developers who write UI for one reason or another. GWT gives you the opportunity to not abandon high-level languages ​​and their advantages. There is already GWT support in IntellijIDEA and Ecipse.

    Example
    public class HelloCrazyWorld implements EntryPoint
    {
        public void onModuleLoad ()
        {
             Label label = new Label ("Click me");
             label .addClickListener (new ClickListener ()
             {
                 public void onClick (Widget sender)
                 {
                     Window.alert ("Hello!");
                 }
            });
           RootPanel.get (). Add (label); 
        }
    }
    


    PS. who will tell you how best to frame the code with tags?

    Also popular now: