ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Quick Course into Vaadin
                                   Jeroen Benats
                            C4J - Java Consultant
                                   jeroen.benats@c4j.be




Thursday 4 October 12
Swing
Thursday 4 October 12
                        ?
Thursday 4 October 12
Thursday 4 October 12
JFrame




Thursday 4 October 12
JFrame
                        BoxLayout




Thursday 4 October 12
JFrame
                        BoxLayout
                          Components
                          FlowLayout




Thursday 4 October 12
Everything you
              already know ...



Thursday 4 October 12
Thursday 4 October 12
SpringLayout
                JButton
                                     JFrame
                        GridLayout
                                   JºÝºÝߣr
                JRadioButton         BorderLayout
                              JList
             JTable
                    JTree           GridBagLayout
                            JMenu
             JTextField                JCheckBox
                        FlowLayout
                            JComboBox    CardLayout
                                 BoxLayout

Thursday 4 October 12
... is VERY easily
       ¡°translated¡± into
                Vaadin ...


Thursday 4 October 12
Thursday 4 October 12
Thursday 4 October 12
Window




Thursday 4 October 12
Window
                 VerticalLayout




Thursday 4 October 12
Window
                 VerticalLayout
                        Components
                        HorizontalLayout




Thursday 4 October 12
Thursday 4 October 12
CustomLayout
                                  Window
                     Button
                 HorizontalLayout   ºÝºÝߣr
                                     AbsoluteLayout
                        RadioButton
               Table
                      Tree           VerticalLayout
                            MenuBar
               TextField                CheckBox
                         GridLayout
                           ComboBox      CssLayout
                                TextArea

Thursday 4 October 12
Contents

         Component
         overview
         Which are available?




Thursday 4 October 12
Contents

         Component
         overview
         Which are available?




         Layouts
         Putting all those
         Components together




Thursday 4 October 12
Contents

         Component
         overview
         Which are available?




         Layouts                Theming
                                Let¡¯s make it all look nice!
         Putting all those
         Components together




Thursday 4 October 12
Contents

         Component
         overview                                      Binding
         Which are available?                          Automatic UI and
                                                       datasource updates



         Layouts                Theming
                                Let¡¯s make it all look nice!
         Putting all those
         Components together




Thursday 4 October 12
Thursday 4 October 12
In Vaadin...

                   Everything is a Component (Interface)




Thursday 4 October 12
In Vaadin...

        Everything is an AbstractComponent (Class)




Thursday 4 October 12
In Vaadin...

            Components that are not bound to a data
            model inherit AbstractComponent directly




Thursday 4 October 12
Building your
         Application




Thursday 4 October 12
A basic Vaadin Application consists of...




                                         tekst




Thursday 4 October 12
A basic Vaadin Application consists of...


                          A Window, set as MainWindow
                          of the Application

                                         tekst




Thursday 4 October 12
A basic Vaadin Application consists of...


                          A Window, set as MainWindow
                          of the Application

                                         tekst
                          Hierarchy of Layout
                          Components




Thursday 4 October 12
A basic Vaadin Application consists of...


                          A Window, set as MainWindow
                          of the Application

                                         tekst
                          Hierarchy of Layout
                          Components


                          Bound and unbound Fields
                          and Components



Thursday 4 October 12
It all comes down to this




Thursday 4 October 12
Learning it
                            quickly
                        the Vaadin
                          Sampler

Thursday 4 October 12
contains
                 all
                 Vaadin
                 Components

Thursday 4 October 12
Immediate
                 demoes
                 of all these
                 Components

Thursday 4 October 12
ready to use
                 code examples
                 to get you going


Thursday 4 October 12
Let¡¯s go through it


Thursday 4 October 12
Basic
                        Component
                          features


Thursday 4 October 12
Thursday 4 October 12
setCaption()
                        setDescription()




Thursday 4 October 12
setCaption()
                        setDescription()


                        attach()
                        detach()




Thursday 4 October 12
setCaption()
                        setDescription()


                        attach()
                        detach()


                        setIcon()
                        setStyleName()



Thursday 4 October 12
Thursday 4 October 12
setEnabled() setVisible()
                        setReadOnly()




Thursday 4 October 12
setEnabled() setVisible()
                        setReadOnly()


                        setLocale()




Thursday 4 October 12
setEnabled() setVisible()
                        setReadOnly()


                        setLocale()


                        setWidth() setSizeFull()
                        setHeight() setSizeUnde?ned()



Thursday 4 October 12
Thursday 4 October 12
Thursday 4 October 12
Now sit and
                        watch this demo
                        application

Thursday 4 October 12
Putting
                        Components
                        into Layouts


Thursday 4 October 12
Thursday 4 October 12
Seeing is
                        believing
                          And also remembering!




Thursday 4 October 12
In Vaadin...

                        All ComponentContainers have the
                         VerticalLayout as default Layout




Thursday 4 October 12
Theming
                        to make it look NICE




Thursday 4 October 12
Thursday 4 October 12
Completely separated
                        from logic




Thursday 4 October 12
Completely separated
                        from logic


                        Done with
                        CSS




Thursday 4 October 12
Completely separated
                        from logic


                        Done with
                        CSS


                        CustomLayouts, images and
                        other resources



Thursday 4 October 12
Thursday 4 October 12
Thursday 4 October 12
Name of the theme folder is
                        the name of your theme




Thursday 4 October 12
Name of the theme folder is
                        the name of your theme


                        styles.css, recourses
                        Layouts




Thursday 4 October 12
Name of the theme folder is
                        the name of your theme


                        styles.css, recourses
                        Layouts


                        setTheme(¡®name¡¯) in
                        Application



Thursday 4 October 12
In Vaadin...

          Images from themes can be loaded via the
                   ThemeResource object




Thursday 4 October 12
In Vaadin...

  They can then be used as Icon on a Component
        or directly in an Embedded object




Thursday 4 October 12
A demo




Thursday 4 October 12
Event driven
      development &
    bandwidth usage


Thursday 4 October 12
Thursday 4 October 12
Thursday 4 October 12
Thursday 4 October 12
Thursday 4 October 12
Thursday 4 October 12
Event driven
                        Application
                        Components

Thursday 4 October 12
Data
                        Binding



Thursday 4 October 12
Thursday 4 October 12
Coupling Components with a
                        datasource




Thursday 4 October 12
Coupling Components with a
                        datasource


                        Updated data in the Component
                        will also update the datasource




Thursday 4 October 12
Coupling Components with a
                        datasource


                        Updated data in the Component
                        will also update the datasource


                        And
                        vice versa



Thursday 4 October 12
Thursday 4 October 12
Property




Thursday 4 October 12
Property
                        Standardized API for a single
                        data object




Thursday 4 October 12
Property
                        Standardized API for a single
                        data object


                        Allows to read and write data
                        from and to this object




Thursday 4 October 12
Property
                        Standardized API for a single
                        data object


                        Allows to read and write data
                        from and to this object


                        Property value changes can be
                        catched with a ValueChangeListener



Thursday 4 October 12
Code fragment

              ?nal	
 ?TextField	
 ?-	
 ?=	
 ?new	
 ?TextField("username:");

              -.addListener(new	
 ?Property.ValueChangeListener()	
 ?{
              	
 ?	
 ?	
 ?	
 ?public	
 ?void	
 ?valueChange(ValueChangeEvent	
 ?event)	
 ?{
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?...
              	
 ?	
 ?	
 ?	
 ?}
              });

              -.setValue("...");




Thursday 4 October 12
Property




Thursday 4 October 12
Property
                        Field Components implement
                        the Property interface




Thursday 4 October 12
Property
                        Field Components implement
                        the Property interface


                        And thereby the Property.Viewer
                        interface




Thursday 4 October 12
Property
                        Field Components implement
                        the Property interface


                        And thereby the Property.Viewer
                        interface

                        Which means they can be bound to any kind
                        of datasource and even to other Components
                        implementing the Viewer interface



Thursday 4 October 12
Code fragment

              TextField	
 ?editor	
 ?=	
 ?new	
 ?TextField("username");
              Label	
 ?viewer	
 ?=	
 ?new	
 ?Label();


              viewer.setPropertyDataSource(editor);
              editor.setImmediate(true);




                  Any change in the text ?eld will immediatly update the Label




Thursday 4 October 12
Item




Thursday 4 October 12
Item
                        Provides access to a set of
                        named Properties




Thursday 4 October 12
Item
                        Provides access to a set of
                        named Properties


                        De?nes inner Interfaces for
                        maintaining the Item Properties set




Thursday 4 October 12
Item
                        Provides access to a set of
                        named Properties


                        De?nes inner Interfaces for
                        maintaining the Item Properties set

                        And Interfaces for listening
                        to changes made to it



Thursday 4 October 12
Code fragment 1
              public	
 ?class	
 ?My_vaadinApplicaOon	
 ?extends	
 ?ApplicaOon	
 ?{
              	
 ?	
 ?	
 ?	
 ?public	
 ?void	
 ?init()	
 ?{
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?Window	
 ?main	
 ?=	
 ?new	
 ?Window("Countries	
 ?Window");

              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?PropertysetItem	
 ?setOfProperOes	
 ?=	
 ?new	
 ?PropertysetItem();
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?setOfProperOes.addItemProperty("?rst	
 ?name¡±,	
 ?new	
 ?ObjectProperty("haim"));
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?setOfProperOes.addItemProperty("last	
 ?name¡±,	
 ?new	
 ?ObjectProperty("michael"));
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?setOfProperOes.addItemProperty("email¡±,	
 ?new	
 ?ObjectProperty("haim@gmaail.com"));

              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?Form	
 ?form	
 ?=	
 ?new	
 ?Form();
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?form.setItemDataSource(setOfProperOes);

              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?setMainWindow(main);
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?main.addComponent(form);
              	
 ?	
 ?	
 ?	
 ?}




Thursday 4 October 12
Code fragment 2
              public	
 ?class	
 ?My_vaadinApplicaOon	
 ?extends	
 ?ApplicaOon	
 ?{

              	
 ?	
 ?	
 ?	
 ?public	
 ?void	
 ?init()	
 ?{
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?Window	
 ?main	
 ?=	
 ?new	
 ?Window("Countries	
 ?Window");

              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?Person	
 ?person	
 ?=	
 ?new	
 ?Person(¡±Jeroen",	
 ?¡±Benats",	
 ?123123);

              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?BeanItem<Person>	
 ?data	
 ?=	
 ?new	
 ?BeanItem<Person>(person);
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?Form	
 ?form	
 ?=	
 ?new	
 ?Form();
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?form.setItemDataSource(data);

              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?setMainWindow(main);
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?main.addComponent(form);
              	
 ?	
 ?	
 ?	
 ?}
              }




Thursday 4 October 12
Container




Thursday 4 October 12
Container
                        Flexible way for managing a set of
                        Items that share common properties




Thursday 4 October 12
Container
                        Flexible way for managing a set of
                        Items that share common properties


                        Each Item within a Container is
                        identi?ed by an ID




Thursday 4 October 12
Container
                        Flexible way for managing a set of
                        Items that share common properties


                        Each Item within a Container is
                        identi?ed by an ID

                        Tree, Table and Select can be bound on
                        Container Objects



Thursday 4 October 12
Code fragment
              public	
 ?class	
 ?My_vaadinApplicaOon	
 ?extends	
 ?ApplicaOon	
 ?{
              	
 ?	
 ?	
 ?	
 ?public	
 ?void	
 ?init()	
 ?{
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?Window	
 ?main	
 ?=	
 ?new	
 ?Window("Countries	
 ?Window");
              	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?setMainWindow(main);

                        BeanItemContainer<Bean> beans = new
                                                    BeanItemContainer<Bean>(Bean.class);
              ????
                        beans.addBean(new                         Bean("Mung bean",   1452.0));
                        beans.addBean(new                         Bean("Chickpea",????686.0));
                        beans.addBean(new                         Bean("Lentil",???? 1477.0));
                        beans.addBean(new                         Bean("Common bean", 129.0));
                        beans.addBean(new                         Bean("Soybean",???? 1866.0));

                        Table table = new Table("Beans of All Sorts", beans);

                        }




Thursday 4 October 12
Thursday 4 October 12
A demo




Thursday 4 October 12
Vaadin Pizzeria



    Let¡¯s try to create your
    ?rst Vaadin
    Application




Thursday 4 October 12
Questions
              Comments




                          jeroe n.benats@c4j.be
                                http://www.c4j.be



Thursday 4 October 12

More Related Content

Quick course into Vaadin

  • 1. Quick Course into Vaadin Jeroen Benats C4J - Java Consultant jeroen.benats@c4j.be Thursday 4 October 12
  • 6. JFrame BoxLayout Thursday 4 October 12
  • 7. JFrame BoxLayout Components FlowLayout Thursday 4 October 12
  • 8. Everything you already know ... Thursday 4 October 12
  • 10. SpringLayout JButton JFrame GridLayout JºÝºÝߣr JRadioButton BorderLayout JList JTable JTree GridBagLayout JMenu JTextField JCheckBox FlowLayout JComboBox CardLayout BoxLayout Thursday 4 October 12
  • 11. ... is VERY easily ¡°translated¡± into Vaadin ... Thursday 4 October 12
  • 15. Window VerticalLayout Thursday 4 October 12
  • 16. Window VerticalLayout Components HorizontalLayout Thursday 4 October 12
  • 18. CustomLayout Window Button HorizontalLayout ºÝºÝߣr AbsoluteLayout RadioButton Table Tree VerticalLayout MenuBar TextField CheckBox GridLayout ComboBox CssLayout TextArea Thursday 4 October 12
  • 19. Contents Component overview Which are available? Thursday 4 October 12
  • 20. Contents Component overview Which are available? Layouts Putting all those Components together Thursday 4 October 12
  • 21. Contents Component overview Which are available? Layouts Theming Let¡¯s make it all look nice! Putting all those Components together Thursday 4 October 12
  • 22. Contents Component overview Binding Which are available? Automatic UI and datasource updates Layouts Theming Let¡¯s make it all look nice! Putting all those Components together Thursday 4 October 12
  • 24. In Vaadin... Everything is a Component (Interface) Thursday 4 October 12
  • 25. In Vaadin... Everything is an AbstractComponent (Class) Thursday 4 October 12
  • 26. In Vaadin... Components that are not bound to a data model inherit AbstractComponent directly Thursday 4 October 12
  • 27. Building your Application Thursday 4 October 12
  • 28. A basic Vaadin Application consists of... tekst Thursday 4 October 12
  • 29. A basic Vaadin Application consists of... A Window, set as MainWindow of the Application tekst Thursday 4 October 12
  • 30. A basic Vaadin Application consists of... A Window, set as MainWindow of the Application tekst Hierarchy of Layout Components Thursday 4 October 12
  • 31. A basic Vaadin Application consists of... A Window, set as MainWindow of the Application tekst Hierarchy of Layout Components Bound and unbound Fields and Components Thursday 4 October 12
  • 32. It all comes down to this Thursday 4 October 12
  • 33. Learning it quickly the Vaadin Sampler Thursday 4 October 12
  • 34. contains all Vaadin Components Thursday 4 October 12
  • 35. Immediate demoes of all these Components Thursday 4 October 12
  • 36. ready to use code examples to get you going Thursday 4 October 12
  • 37. Let¡¯s go through it Thursday 4 October 12
  • 38. Basic Component features Thursday 4 October 12
  • 40. setCaption() setDescription() Thursday 4 October 12
  • 41. setCaption() setDescription() attach() detach() Thursday 4 October 12
  • 42. setCaption() setDescription() attach() detach() setIcon() setStyleName() Thursday 4 October 12
  • 44. setEnabled() setVisible() setReadOnly() Thursday 4 October 12
  • 45. setEnabled() setVisible() setReadOnly() setLocale() Thursday 4 October 12
  • 46. setEnabled() setVisible() setReadOnly() setLocale() setWidth() setSizeFull() setHeight() setSizeUnde?ned() Thursday 4 October 12
  • 49. Now sit and watch this demo application Thursday 4 October 12
  • 50. Putting Components into Layouts Thursday 4 October 12
  • 52. Seeing is believing And also remembering! Thursday 4 October 12
  • 53. In Vaadin... All ComponentContainers have the VerticalLayout as default Layout Thursday 4 October 12
  • 54. Theming to make it look NICE Thursday 4 October 12
  • 56. Completely separated from logic Thursday 4 October 12
  • 57. Completely separated from logic Done with CSS Thursday 4 October 12
  • 58. Completely separated from logic Done with CSS CustomLayouts, images and other resources Thursday 4 October 12
  • 61. Name of the theme folder is the name of your theme Thursday 4 October 12
  • 62. Name of the theme folder is the name of your theme styles.css, recourses Layouts Thursday 4 October 12
  • 63. Name of the theme folder is the name of your theme styles.css, recourses Layouts setTheme(¡®name¡¯) in Application Thursday 4 October 12
  • 64. In Vaadin... Images from themes can be loaded via the ThemeResource object Thursday 4 October 12
  • 65. In Vaadin... They can then be used as Icon on a Component or directly in an Embedded object Thursday 4 October 12
  • 66. A demo Thursday 4 October 12
  • 67. Event driven development & bandwidth usage Thursday 4 October 12
  • 73. Event driven Application Components Thursday 4 October 12
  • 74. Data Binding Thursday 4 October 12
  • 76. Coupling Components with a datasource Thursday 4 October 12
  • 77. Coupling Components with a datasource Updated data in the Component will also update the datasource Thursday 4 October 12
  • 78. Coupling Components with a datasource Updated data in the Component will also update the datasource And vice versa Thursday 4 October 12
  • 81. Property Standardized API for a single data object Thursday 4 October 12
  • 82. Property Standardized API for a single data object Allows to read and write data from and to this object Thursday 4 October 12
  • 83. Property Standardized API for a single data object Allows to read and write data from and to this object Property value changes can be catched with a ValueChangeListener Thursday 4 October 12
  • 84. Code fragment ?nal ?TextField ?- ?= ?new ?TextField("username:"); -.addListener(new ?Property.ValueChangeListener() ?{ ? ? ? ?public ?void ?valueChange(ValueChangeEvent ?event) ?{ ? ? ? ? ? ? ? ?... ? ? ? ?} }); -.setValue("..."); Thursday 4 October 12
  • 86. Property Field Components implement the Property interface Thursday 4 October 12
  • 87. Property Field Components implement the Property interface And thereby the Property.Viewer interface Thursday 4 October 12
  • 88. Property Field Components implement the Property interface And thereby the Property.Viewer interface Which means they can be bound to any kind of datasource and even to other Components implementing the Viewer interface Thursday 4 October 12
  • 89. Code fragment TextField ?editor ?= ?new ?TextField("username"); Label ?viewer ?= ?new ?Label(); viewer.setPropertyDataSource(editor); editor.setImmediate(true); Any change in the text ?eld will immediatly update the Label Thursday 4 October 12
  • 91. Item Provides access to a set of named Properties Thursday 4 October 12
  • 92. Item Provides access to a set of named Properties De?nes inner Interfaces for maintaining the Item Properties set Thursday 4 October 12
  • 93. Item Provides access to a set of named Properties De?nes inner Interfaces for maintaining the Item Properties set And Interfaces for listening to changes made to it Thursday 4 October 12
  • 94. Code fragment 1 public ?class ?My_vaadinApplicaOon ?extends ?ApplicaOon ?{ ? ? ? ?public ?void ?init() ?{ ? ? ? ? ? ? ? ?Window ?main ?= ?new ?Window("Countries ?Window"); ? ? ? ? ? ? ? ?PropertysetItem ?setOfProperOes ?= ?new ?PropertysetItem(); ? ? ? ? ? ? ? ?setOfProperOes.addItemProperty("?rst ?name¡±, ?new ?ObjectProperty("haim")); ? ? ? ? ? ? ? ?setOfProperOes.addItemProperty("last ?name¡±, ?new ?ObjectProperty("michael")); ? ? ? ? ? ? ? ?setOfProperOes.addItemProperty("email¡±, ?new ?ObjectProperty("haim@gmaail.com")); ? ? ? ? ? ? ? ?Form ?form ?= ?new ?Form(); ? ? ? ? ? ? ? ?form.setItemDataSource(setOfProperOes); ? ? ? ? ? ? ? ?setMainWindow(main); ? ? ? ? ? ? ? ?main.addComponent(form); ? ? ? ?} Thursday 4 October 12
  • 95. Code fragment 2 public ?class ?My_vaadinApplicaOon ?extends ?ApplicaOon ?{ ? ? ? ?public ?void ?init() ?{ ? ? ? ? ? ? ? ?Window ?main ?= ?new ?Window("Countries ?Window"); ? ? ? ? ? ? ? ?Person ?person ?= ?new ?Person(¡±Jeroen", ?¡±Benats", ?123123); ? ? ? ? ? ? ? ?BeanItem<Person> ?data ?= ?new ?BeanItem<Person>(person); ? ? ? ? ? ? ? ?Form ?form ?= ?new ?Form(); ? ? ? ? ? ? ? ?form.setItemDataSource(data); ? ? ? ? ? ? ? ?setMainWindow(main); ? ? ? ? ? ? ? ?main.addComponent(form); ? ? ? ?} } Thursday 4 October 12
  • 97. Container Flexible way for managing a set of Items that share common properties Thursday 4 October 12
  • 98. Container Flexible way for managing a set of Items that share common properties Each Item within a Container is identi?ed by an ID Thursday 4 October 12
  • 99. Container Flexible way for managing a set of Items that share common properties Each Item within a Container is identi?ed by an ID Tree, Table and Select can be bound on Container Objects Thursday 4 October 12
  • 100. Code fragment public ?class ?My_vaadinApplicaOon ?extends ?ApplicaOon ?{ ? ? ? ?public ?void ?init() ?{ ? ? ? ? ? ? ? ?Window ?main ?= ?new ?Window("Countries ?Window"); ? ? ? ? ? ? ? ?setMainWindow(main); BeanItemContainer<Bean> beans = new BeanItemContainer<Bean>(Bean.class); ???? beans.addBean(new Bean("Mung bean", 1452.0)); beans.addBean(new Bean("Chickpea",????686.0)); beans.addBean(new Bean("Lentil",???? 1477.0)); beans.addBean(new Bean("Common bean", 129.0)); beans.addBean(new Bean("Soybean",???? 1866.0)); Table table = new Table("Beans of All Sorts", beans); } Thursday 4 October 12
  • 102. A demo Thursday 4 October 12
  • 103. Vaadin Pizzeria Let¡¯s try to create your ?rst Vaadin Application Thursday 4 October 12
  • 104. Questions Comments jeroe n.benats@c4j.be http://www.c4j.be Thursday 4 October 12