Rich Web Applications in
                                   Server-side Java without
                                     Plug-ins or JavaScript
twitter: #vaadin @joonaslehtinen




                                              Joonas Lehtinen, PhD
                                                  Vaadin Ltd - CEO
                                                     joonas@vaadin.com




  sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
Vaadin is a
                UI framework
              for desktop-like
                     web apps


sunnuntaina 13. helmikuuta 2011
New configs,
    taglibs and
    syntax!?!

            No! {
    JavaScript,
    DOM, Applet,
    plugins?
                                  This is
                                  Nothin  Java.
                                         g else
                                               .


sunnuntaina 13. helmikuuta 2011
java                   html

sunnuntaina 13. helmikuuta 2011
healthcare portal, 100 kloc of perl, ..
                                    89
                                  19




sunnuntaina 13. helmikuuta 2011
web 1.0, netscape, ie5, ie6, ...




sunnuntaina 13. helmikuuta 2011
thinking of
   object oriented design, desktop, Java, U and I ...




sunnuntaina 13. helmikuuta 2011
desktop programming paradigm for web!




sunnuntaina 13. helmikuuta 2011
found                                millstone ajax google web toolkit
            00




                                                    08
                                   02




                                              05
        20




                                  20




                                             20



                                                   20




sunnuntaina 13. helmikuuta 2011
re-released as
                          09
                      20




sunnuntaina 13. helmikuuta 2011
Vaadin is now
       21 months young
        and 10 years old


sunnuntaina 13. helmikuuta 2011
Apache
                                  License

sunnuntaina 13. helmikuuta 2011
Contents

         Server-side                                         Discussion
         RIA
         What is it? Pros & cons?



                                    Vaadin
                                    Big picture, Extending, Getting started
         In practice
         Coding a Vaadin
         application step-by-step



sunnuntaina 13. helmikuuta 2011
Server-side RIA



sunnuntaina 13. helmikuuta 2011
“Web 1.0”

                      Client              5
                                                               Server
                                     HTML Page
                        DOM       over HttpResponse     View                4


                                                                                 3
                                                                   Model

                                    Parameters over
                                     HttpRequest
                                                      Controller
                                                                        2
                                                                                DB
                                          1




sunnuntaina 13. helmikuuta 2011
Client-side RIA

                        Client                  4                     Server
                                          Requested data
                           View             to view as
                                           XML / JSON
                                  5

                          DOM                                 Model
                                                                          3
                                  1

                                        Changes to model
                       Controller     encoded as parameters
                                                                               DB
                                                2




sunnuntaina 13. helmikuuta 2011
challenge
                                    web is
                                  not easy


sunnuntaina 13. helmikuuta 2011
different
                 features
                 in different
                 browsers

sunnuntaina 13. helmikuuta 2011
different
                 performance
                 in different
                 browsers

sunnuntaina 13. helmikuuta 2011
different
                 bugs
                 in different
                 browsers

sunnuntaina 13. helmikuuta 2011
Google Web Toolkit


sunnuntaina 13. helmikuuta 2011
Subset of                        IE6
             java.lang, java.util

                                       Java to     IE7
                         Widgetset   JavaScript
                                      Compiler
                                                  Firefox

            Your Application UI                   Safari




sunnuntaina 13. helmikuuta 2011
simpler
                 • Java only
                 • forget the web


sunnuntaina 13. helmikuuta 2011
cost-effective
                 stop debugging
                 JavaScript spaghetti


sunnuntaina 13. helmikuuta 2011
♲                             modular
                                  extensible


sunnuntaina 13. helmikuuta 2011
Building wonderful
                 apps doesn’t
                 require writing fat
                 web clients.

sunnuntaina 13. helmikuuta 2011
Server-side RIA

                    Client                                      8
                                                                                                        Server
                                  9                                                            7
                                      TerminalAdapter




                                                                             TerminalAdapter
                                                           HTML Page
                                                        over HttpResponse                            View            6


                                                           Automated by                                                   5
                    DOM                                  the RIA framework                                      Model

                                                         Parameters over
                                                          HttpRequest                              Controller
                                  1                                                                              4
                                                                                               3                         DB
                                                                2




sunnuntaina 13. helmikuuta 2011
Server-side RIA

                    Client                                      8
                                                                                                        Server
                                  9                                                            7
                                      TerminalAdapter




                                                                             TerminalAdapter
                                                           HTML Page
                                                        over HttpResponse                            View            6


                                                           Automated by                                                   5
                    DOM                                  the RIA framework                                      Model

    Handled by the framework                             Parameters over
                                                          HttpRequest                              Controller
                                  1                                                                              4
                                                                                               3                         DB
                                                                2




sunnuntaina 13. helmikuuta 2011
the benefits
    of Java
                                  simpler
                                  forget the web

         Java
                                  cost-effective
                                  no JavaScript
                                  debugging


                                  modular
                                  extensible   ♲
sunnuntaina 13. helmikuuta 2011
even simpler
                 • forget the client-side
                 • synchronous
                 • server resources

sunnuntaina 13. helmikuuta 2011
more flexible
                 • all Java tools and
                   libraries
                 • any JVM language
                  Scala       Groovy
sunnuntaina 13. helmikuuta 2011
more secure
                 • code stays in server
                 • less web services


sunnuntaina 13. helmikuuta 2011
not as scalable
                 UI state is stored in
                 the server memory


sunnuntaina 13. helmikuuta 2011
Measured 12.000
                 active concurrent
                 users per server
                 for a ticketing app
        [Amazon EC2-large; limited by storage layer]


sunnuntaina 13. helmikuuta 2011
no offline mode
                 server is always
                 required


sunnuntaina 13. helmikuuta 2011
#1 benefit
                              development
                               is really fast


sunnuntaina 13. helmikuuta 2011
Vaadin
                                  Framework



sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
                                   1
                                  Great UI
                                  Components
sunnuntaina 13. helmikuuta 2011
Combined power of
                                  • Server-side RIA
                                  • Google Web Toolkit



sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
                                  2
                                  Combined power of
                                  • Server-side RIA
                                  • Google Web Toolkit
Vaadin UI component
    architecture
                                       HTTP(S)
          “UI Component”                         “Widget”
          • Button, Table, Tree, ...             • Client-side peer for
          • Server-side data                       the component
          • Full Java API                        • Runs on JavaScript




               Java                               Java

               • Compiled with JDK                • Google Web Toolkit



sunnuntaina 13. helmikuuta 2011
Creating new UI
                 components is
                 really easy


sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
Implement two classes

      Server-side                               Client-side

          “UI Component”            Automatic    “Widget”
          • Define API                            • Render to DOM
          • Receive client events                • Collect user events
          • Send UI updates
            back




sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
First class
                                  Java citizen



sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
                                  3
                                  First class
                                  Java citizen
Servlet
                          Portlet
                      App Engine

sunnuntaina 13. helmikuuta 2011
Eclipse
                            Maven
                         Netbeans
                        Spring Roo

sunnuntaina 13. helmikuuta 2011
PROD
UCTIV
I
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
persistence setup --provider HIBERNATE
    --database HYPERSONIC_IN_MEMORY

   entity --class ~.domain.Topping
   field string --fieldName name --notNull

   entity --class ~.domain.Pizza
   field number --fieldName price
    --type java.lang.Float
   field set --fieldName toppings
    --type ~.domain.Topping

sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
vaadin setup
    --applicationPackage ~.web
    --baseName PizzaShop
    --themeName pizza
    --useJpaContainer false

   vaadin generate all
    --package ~.web.ui
    --visuallyComposable true


sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
field string --class ~.domain.Pizza
    --notNull --fieldName name --sizeMin 3




sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
getting
                 started


sunnuntaina 13. helmikuuta 2011
sunnuntaina 13. helmikuuta 2011
Vaadin is
                  a
      for build n open source
                ing mod         J
     look gre           ern web ava framework
               at,             app
     your use perform well an lications that
               rs happ          d make
                       y.              you and
    http://va
                adin.com
                           /



  ISBN 978
           -9   52-92-67
                               53-8
                                      90000

   GET A
   Free
  9 78952
          9        267538
US $24.9
        5




                                                 Vaadin 6




   Copy
                                                          .4 Edition




sunnuntaina 13. helmikuuta 2011
brought to you by...
 #85Get More Refcardz! Visit refcardz.com


                                            CONTENTS INCLUDE:
                                            About Vaadin


                                                                                      Getting Started with Vaadin
                                            Creating An Application
                                            Components
                                            Layout Components
                                            Themes
                                            Data Binding and more...
                                                                                                                                                               By Marko Grönroos

                                                 ABOUT VAADIN                                                         Web
                                                                                                                      Browser                                                              External
                                                                                                                      Client-Side                                                          Resources
                                             Vaadin is a server-side Ajax web application development                 Engine
                                             framework that allows you to build web applications just like                     AJAX Requests

                                             with traditional desktop frameworks, such as AWT or Swing. An                                         Servlet Container
                                                                                                                      Java                                                                 File
                                             application is built from user interface components contained            Servlet                                                              Resources
                                             hierarchically in layout components.
                                                                                                                                                           Data
                                             In the server-driven model, the application code runs on                 Application            UI            Binding     Default
                                                                                                                      Class                  Component                 Theme
                                             a server, while the actual user interaction is handled by a
                                             client-side engine running in the browser. The client-server           Inherits        Events     Changes               Inherits

                                             communications and any client-side technologies, such as                 User             Event        Data              Application   Application
                                             HTML and JavaScript, are invisible to the developer. As the              Application      Listener     Model             Themes        Resources
                                             client-side engine runs as JavaScript in the browser, there is no
                                             need to install plug-ins. Vaadin is released under the Apache                                            Database
                                             License 2.0.
                                              Web             Java         Vaadin          Your             Web    Figure 2: Architecture for Vaadin Applications
                                              Browser         Web          UI              Java          Service
                                              Client-Side     Server       Components      Application
                                                                                                                                     You can get a reference to the application object
    w.dzone.com




                                              Engine                                                        EJB          Hot
                                                                                                                         Tip         from any component attached to the application with
                                                                                                             DB

                                                                                                                   Event Listeners
                                             Figure 1: Vaadin Client-Server Architecture
                                                                                                                   In the event-driven model, user interaction with user interface
                   If the built-in selection of components is not enough, you can
                                                                                                                   components triggers server-side events, which you can handle
sunnuntaina 13. helmikuuta 2011 components with the Google Web Toolkit (GWT)
                   develop new
Forums with
  1000 msgs/m


                                                Ask the
                                  [really active, world wide]
           102,776
                                         Community
sunnuntaina 13. helmikuuta 2011
Questions
               Comments




                                  joon as@vaadin.com
                                      vaadin.com/joonas
                                       twitter: joonaslehtinen


sunnuntaina 13. helmikuuta 2011

Vaadin - Rich Web Apps in Server-Side Java without Plug-ins or JavaScript

  • 1.
    Rich Web Applicationsin Server-side Java without Plug-ins or JavaScript twitter: #vaadin @joonaslehtinen Joonas Lehtinen, PhD Vaadin Ltd - CEO joonas@vaadin.com sunnuntaina 13. helmikuuta 2011
  • 2.
  • 3.
    Vaadin is a UI framework for desktop-like web apps sunnuntaina 13. helmikuuta 2011
  • 4.
    New configs, taglibs and syntax!?! No! { JavaScript, DOM, Applet, plugins? This is Nothin Java. g else . sunnuntaina 13. helmikuuta 2011
  • 5.
    java html sunnuntaina 13. helmikuuta 2011
  • 6.
    healthcare portal, 100kloc of perl, .. 89 19 sunnuntaina 13. helmikuuta 2011
  • 7.
    web 1.0, netscape,ie5, ie6, ... sunnuntaina 13. helmikuuta 2011
  • 8.
    thinking of object oriented design, desktop, Java, U and I ... sunnuntaina 13. helmikuuta 2011
  • 9.
    desktop programming paradigmfor web! sunnuntaina 13. helmikuuta 2011
  • 10.
    found millstone ajax google web toolkit 00 08 02 05 20 20 20 20 sunnuntaina 13. helmikuuta 2011
  • 11.
    re-released as 09 20 sunnuntaina 13. helmikuuta 2011
  • 12.
    Vaadin is now 21 months young and 10 years old sunnuntaina 13. helmikuuta 2011
  • 13.
    Apache License sunnuntaina 13. helmikuuta 2011
  • 14.
    Contents Server-side Discussion RIA What is it? Pros & cons? Vaadin Big picture, Extending, Getting started In practice Coding a Vaadin application step-by-step sunnuntaina 13. helmikuuta 2011
  • 15.
  • 16.
    “Web 1.0” Client 5 Server HTML Page DOM over HttpResponse View 4 3 Model Parameters over HttpRequest Controller 2 DB 1 sunnuntaina 13. helmikuuta 2011
  • 17.
    Client-side RIA Client 4 Server Requested data View to view as XML / JSON 5 DOM Model 3 1 Changes to model Controller encoded as parameters DB 2 sunnuntaina 13. helmikuuta 2011
  • 18.
    challenge web is not easy sunnuntaina 13. helmikuuta 2011
  • 19.
    different features in different browsers sunnuntaina 13. helmikuuta 2011
  • 20.
    different performance in different browsers sunnuntaina 13. helmikuuta 2011
  • 21.
    different bugs in different browsers sunnuntaina 13. helmikuuta 2011
  • 22.
    Google Web Toolkit sunnuntaina13. helmikuuta 2011
  • 23.
    Subset of IE6 java.lang, java.util Java to IE7 Widgetset JavaScript Compiler Firefox Your Application UI Safari sunnuntaina 13. helmikuuta 2011
  • 24.
    simpler • Java only • forget the web sunnuntaina 13. helmikuuta 2011
  • 25.
    cost-effective stop debugging JavaScript spaghetti sunnuntaina 13. helmikuuta 2011
  • 26.
    modular extensible sunnuntaina 13. helmikuuta 2011
  • 27.
    Building wonderful apps doesn’t require writing fat web clients. sunnuntaina 13. helmikuuta 2011
  • 28.
    Server-side RIA Client 8 Server 9 7 TerminalAdapter TerminalAdapter HTML Page over HttpResponse View 6 Automated by 5 DOM the RIA framework Model Parameters over HttpRequest Controller 1 4 3 DB 2 sunnuntaina 13. helmikuuta 2011
  • 29.
    Server-side RIA Client 8 Server 9 7 TerminalAdapter TerminalAdapter HTML Page over HttpResponse View 6 Automated by 5 DOM the RIA framework Model Handled by the framework Parameters over HttpRequest Controller 1 4 3 DB 2 sunnuntaina 13. helmikuuta 2011
  • 30.
    the benefits of Java simpler forget the web Java cost-effective no JavaScript debugging modular extensible ♲ sunnuntaina 13. helmikuuta 2011
  • 31.
    even simpler • forget the client-side • synchronous • server resources sunnuntaina 13. helmikuuta 2011
  • 32.
    more flexible • all Java tools and libraries • any JVM language Scala Groovy sunnuntaina 13. helmikuuta 2011
  • 33.
    more secure • code stays in server • less web services sunnuntaina 13. helmikuuta 2011
  • 34.
    not as scalable UI state is stored in the server memory sunnuntaina 13. helmikuuta 2011
  • 35.
    Measured 12.000 active concurrent users per server for a ticketing app [Amazon EC2-large; limited by storage layer] sunnuntaina 13. helmikuuta 2011
  • 36.
    no offline mode server is always required sunnuntaina 13. helmikuuta 2011
  • 37.
    #1 benefit development is really fast sunnuntaina 13. helmikuuta 2011
  • 38.
    Vaadin Framework sunnuntaina 13. helmikuuta 2011
  • 39.
    sunnuntaina 13. helmikuuta2011 1 Great UI Components
  • 40.
  • 41.
    Combined power of • Server-side RIA • Google Web Toolkit sunnuntaina 13. helmikuuta 2011
  • 42.
    sunnuntaina 13. helmikuuta2011 2 Combined power of • Server-side RIA • Google Web Toolkit
  • 43.
    Vaadin UI component architecture HTTP(S) “UI Component” “Widget” • Button, Table, Tree, ... • Client-side peer for • Server-side data the component • Full Java API • Runs on JavaScript Java Java • Compiled with JDK • Google Web Toolkit sunnuntaina 13. helmikuuta 2011
  • 44.
    Creating new UI components is really easy sunnuntaina 13. helmikuuta 2011
  • 45.
  • 46.
    Implement two classes Server-side Client-side “UI Component” Automatic “Widget” • Define API • Render to DOM • Receive client events • Collect user events • Send UI updates back sunnuntaina 13. helmikuuta 2011
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
    First class Java citizen sunnuntaina 13. helmikuuta 2011
  • 54.
    sunnuntaina 13. helmikuuta2011 3 First class Java citizen
  • 55.
    Servlet Portlet App Engine sunnuntaina 13. helmikuuta 2011
  • 56.
    Eclipse Maven Netbeans Spring Roo sunnuntaina 13. helmikuuta 2011
  • 57.
  • 58.
  • 59.
    persistence setup --providerHIBERNATE --database HYPERSONIC_IN_MEMORY entity --class ~.domain.Topping field string --fieldName name --notNull entity --class ~.domain.Pizza field number --fieldName price --type java.lang.Float field set --fieldName toppings --type ~.domain.Topping sunnuntaina 13. helmikuuta 2011
  • 60.
  • 61.
  • 62.
    vaadin setup --applicationPackage ~.web --baseName PizzaShop --themeName pizza --useJpaContainer false vaadin generate all --package ~.web.ui --visuallyComposable true sunnuntaina 13. helmikuuta 2011
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
    field string --class~.domain.Pizza --notNull --fieldName name --sizeMin 3 sunnuntaina 13. helmikuuta 2011
  • 69.
  • 70.
    getting started sunnuntaina 13. helmikuuta 2011
  • 71.
  • 72.
    Vaadin is a for build n open source ing mod J look gre ern web ava framework at, app your use perform well an lications that rs happ d make y. you and http://va adin.com / ISBN 978 -9 52-92-67 53-8 90000 GET A Free 9 78952 9 267538 US $24.9 5 Vaadin 6 Copy .4 Edition sunnuntaina 13. helmikuuta 2011
  • 73.
    brought to youby... #85Get More Refcardz! Visit refcardz.com CONTENTS INCLUDE: About Vaadin Getting Started with Vaadin Creating An Application Components Layout Components Themes Data Binding and more... By Marko Grönroos ABOUT VAADIN Web Browser External Client-Side Resources Vaadin is a server-side Ajax web application development Engine framework that allows you to build web applications just like AJAX Requests with traditional desktop frameworks, such as AWT or Swing. An Servlet Container Java File application is built from user interface components contained Servlet Resources hierarchically in layout components. Data In the server-driven model, the application code runs on Application UI Binding Default Class Component Theme a server, while the actual user interaction is handled by a client-side engine running in the browser. The client-server Inherits Events Changes Inherits communications and any client-side technologies, such as User Event Data Application Application HTML and JavaScript, are invisible to the developer. As the Application Listener Model Themes Resources client-side engine runs as JavaScript in the browser, there is no need to install plug-ins. Vaadin is released under the Apache Database License 2.0. Web Java Vaadin Your Web Figure 2: Architecture for Vaadin Applications Browser Web UI Java Service Client-Side Server Components Application You can get a reference to the application object w.dzone.com Engine EJB Hot Tip from any component attached to the application with DB Event Listeners Figure 1: Vaadin Client-Server Architecture In the event-driven model, user interaction with user interface If the built-in selection of components is not enough, you can components triggers server-side events, which you can handle sunnuntaina 13. helmikuuta 2011 components with the Google Web Toolkit (GWT) develop new
  • 74.
    Forums with 1000 msgs/m Ask the [really active, world wide] 102,776 Community sunnuntaina 13. helmikuuta 2011
  • 75.
    Questions Comments joon as@vaadin.com vaadin.com/joonas twitter: joonaslehtinen sunnuntaina 13. helmikuuta 2011