You are previewing Learning Vaadin.
O'Reilly logo
Learning Vaadin

Book Description

RHaving a command of the Vaadin framework means your Java web applications will look and perform brilliantly. Learn how with this all-inclusive, step-by-step tutorial to mastering Rich Internet Application development.

  • Discover the Vaadin framework in a progressive and structured way

  • Learn about components, events, layouts, containers, and bindings

  • Create outstanding new components by yourself

  • Integrate with your existing frameworks and infrastructure

  • Pragmatic and no-nonsense approach

  • In Detail

    Vaadin is a new Java web framework for making applications look great and perform well, making your users happy. Vaadin promises to make your user interfaces attractive and usable while easing your development efforts and boosting your productivity. With this book in hand you will be able to utilize the full range of development and deployment features offered by Vaadin while thoroughly understanding the concepts.

    Learning Vaadin is a practical step-by-step tutorial to understanding, using, and mastering the art of RIA development with Vaadin. You will learn about the fundamental concepts that are the cornerstones of the framework, at the same time making progress on building your own web application. The book will also show you how to integrate Vaadin with other popular frameworks and how to run it on top of internal as well as externalized infrastructures.

    This book will show you how to become a professional Vaadin developer by giving you a concrete foundation through diagrams, practical examples and ready-to-use source code. It will enable you to grasp all the notions behind Vaadin one step at a time: components, layouts, events, containers, and bindings. You will learn to build first-class web applications using best-of-breed technologies. You will find detailed information on how to integrate Vaadin's presentation layer on top of other widespread technologies, such as Spring, CDI, and JPA. Finally, the book will show you how to deploy on different infrastructures like Liferay portlet container and Google App Engine.

    An authoritative and complete step-by-step tutorial on how to create top-notch web applications with the RIA Vaadin framework

    "

    Table of Contents

    1. Learning Vaadin
      1. Table of Contents
      2. Learning Vaadin
      3. Credits
      4. Foreword
      5. About the Author
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code for this book
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Vaadin and its context
        1. Rich applications
          1. Application tiers
            1. Tiers migration
              1. Mainframes
              2. Client server
              3. Thin clients
          2. Limitations of the thin-client applications approach
            1. Poor choice of controls
            2. Many unrelated technologies
            3. Browser compatibility
            4. Page flow paradigm
          3. Beyond the limits
            1. What are rich clients?
            2. Some rich client approaches
              1. Ajax
              2. Richness through a plugin
              3. Deploying and updating fat-client from the web
                1. Java Web Start
                2. Update sites
              4. Google Web Toolkit
        2. Why Vaadin?
          1. State of the market
          2. Importance of Vaadin
          3. Vaadin's integration
            1. Integrated frameworks
            2. Integration platforms
          4. Using Vaadin in the real world
            1. Concerns about using a new technology
            2. More reasons
              1. Vaadin is 10 years old
              2. Others already use Vaadin
        3. Summary
      10. 2. Environment Setup
        1. Vaadin in Eclipse
          1. Setting up Eclipse
            1. When Eclipse is not installed
            2. Installing the Vaadin plugin
            3. Creating a server runtime
            4. Creating our first Eclipse Vaadin project
            5. Testing our application
          2. Alternatives
            1. Vendor-specific distribution
            2. When Eclipse is already installed
              1. Checking if WTP is present
              2. Adding WTP to Eclipse
        2. Vaadin in NetBeans
          1. Setting up NetBeans
            1. Checking if Java Web features are present
            2. Checking if the Vaadin plugin is installed
            3. Installing the Vaadin plugin
          2. Creating our first NetBeans Vaadin project
            1. Changing the Vaadin version
          3. Testing the application
        3. Vaadin and other IDEs
          1. Adding the Vaadin library
          2. Creating the application
          3. Adding the servlet mapping
            1. Declaring the servlet class
            2. Declaring the Vaadin's entry point
            3. Declaring the servlet mapping
        4. Summary
      11. 3. Hello Vaadin!
        1. Understanding Vaadin
          1. Vaadin's philosophy
          2. Vaadin's architecture
            1. Client server communication
              1. HTTP protocol
              2. JSON message format
              3. UIDL "schema"
            2. The client part
            3. The server part
            4. Terminal and adapter
            5. Client server synchronization
        2. Deploying a Vaadin application
          1. Inside the IDE
            1. Creating an IDE-managed server
              1. Selecting the tab
              2. Creating a server
              3. Verifying the installation
            2. Adding the application
            3. Launching the server
          2. Outside the IDE
            1. Creating the WAR
            2. Launching the server
        3. Using Vaadin applications
          1. Browsing Vaadin
          2. Out-of-the-box helpers
            1. The debug mode
            2. Restart the application, not the server
        4. Behind the surface
          1. Stream redirection to Vaadin servlet
          2. Vaadin request handling
          3. What does an application do?
            1. Application responsibilities
            2. Application configuration
            3. Application and session
            4. Scratching the surface
            5. The source code
            6. The generated code
            7. Things of interest
        5. Summary
      12. 4. Components and Layouts
        1. Thinking in components
          1. Terminology
          2. Component class design
            1. Component
            2. MethodEventSource
            3. Abstract component
              1. Immediate mode
          3. Windows
            1. ComponentContainer
            2. Panel
            3. Window
              1. Title
              2. Theming
              3. URL fragment
              4. JavaScript
              5. Third-party content
              6. User messages
                1. The notification class
                2. Notifications additional properties
                3. Displaying notifications
            4. Subwindow
              1. Subwindow structure
              2. Customizing subwindows
                1. Basic configuration
                2. Location
                3. Modality
          4. Labels
            1. Label class hierarchy
            2. Property
            3. Label
              1. Formats
          5. Text inputs
            1. Validation
              1. Validator
                1. Validators hierarchy
                2. Error message
              2. Validatable
            2. Change buffer
              1. Buffered and validatable
            3. Input
              1. Focusable
              2. Field
              3. The text field
                1. Null
                2. Input prompt
                3. Cursor
                4. Selection
                5. A "real-world" text field example
        2. Laying out the components
          1. Size
          2. Layouts
            1. About layouts
            2. Layout and abstract layout
            3. Layout types
            4. Choosing the right layout
            5. Split panels
        3. Bringing it all together
          1. Introducing Twaattin
            1. The Twaattin design
            2. The login window
            3. The main window
          2. Let's code!
            1. Project setup
            2. Project sources
              1. Application
              2. The login window
              3. The timeline window
        4. Summary
      13. 5. Event listener model
        1. Event-driven model
          1. The observer pattern
            1. Enhancements to the pattern
              1. Event
              2. Event details
              3. Event types
          2. Events in Java EE
            1. UI events
              1. Client-server events
              2. Client events
              3. Limitations of URL and JS for events
        2. Event model in Vaadin
          1. Standard event implementation
            1. Event class hierarchy
              1. Event
              2. Typed events
            2. Listener interfaces
              1. Window
            3. Managing listeners
              1. Multi-implementations listeners
          2. Alternative event implementation
            1. Method event source details
            2. Listener methods
              1. Return value discard
            3. Parameter types
            4. Abstract component and event router
          3. Expanding our view
            1. Button
          4. Events outside UI
            1. User changed event
          5. Architectural considerations
            1. Anonymous inner classes as listeners
            2. Widgets as listeners
            3. Presenters as listeners
            4. Services as listeners
            5. Conclusion on architecture
          6. Twaattin is back
            1. Project sources
              1. The login window
              2. Application
            2. Additional features
              1. The timeline window
              2. TwaattinApp
        3. Summary
      14. 6. Containers and Related Widgets
        1. Data binding
          1. Data binding properties
            1. Renderer and editor
            2. Buffering
            3. Data binding
        2. Data in Vaadin
          1. Entity abstraction
            1. Property
              1. Object property
              2. Property formatter
                1. Handling changes
            2. Item
              1. Method property
              2. The right level of abstraction
              3. Easy commit with forms
                1. Configuring field types
                2. Ordering fields
                3. Changing captions
                4. Overall form configuration
            3. Container
              1. Filtering and sorting
                1. Filterable
                2. Filter
                3. Ordered
                4. Item sorter
                5. Concrete indexed containers
              2. Hierarchical
          2. Containers and the GUI
            1. Container data source
              1. Displaying items
              2. Handling new items
              3. Null items
            2. Container widgets
            3. Tables
              1. Table structure
              2. Columns
                1. Collapsing
                2. Header and footer
                3. Row header column
                4. Ordering and reordering
                5. Formatting properties and generated columns
              3. Sorting
                1. User sorting
                2. Programmatic sorting
              4. Viewpoint
                1. Viewpoint change event
                2. Improving responsiveness
              5. Editing
              6. Selection
              7. Drag-and-drop
                1. Transferable
                2. Drag source
                3. Drop target
                4. Accept criterion
                5. Table drag-and-drop
            4. Trees
              1. Collapse and expand
              2. Parent and child
              3. Item labels
        3. Refining Twaattin
          1. Requisites
          2. Adaptations
          3. Sources
            1. The login window
            2. The Twaattin application
            3. The timeline window
            4. The name column generator
            5. The date column generator
        4. Summary
      15. 7. Advanced Features
        1. Core features
          1. Accessing with the request-response model
            1. The brute force approach
            2. The integrated approach
          2. Bookmarks
            1. URL fragment
            2. URI fragment utility
          3. Embedding Vaadin
            1. Basic embedding
            2. Nominal embedding
              1. Configuration
              2. Loading
              3. Style sheet
              4. Div
          4. Custom error handling
            1. Design
              1. Error messages
            2. Error listener example
              1. Application
              2. The listener
          5. Lifecycles
            1. Application lifecycle
        2. Third-party additional features
          1. Vaadin add-ons
            1. Add-ons directory
              1. Add-ons search
                1. Typology
                2. Stability
              2. Add-ons presentation
                1. Summarized view
                2. Detailed view
            2. Noteworthy add-ons
              1. Cross-site embedding
              2. Use-case
                1. Tweaks
                2. Installation
                3. Compilation
                4. Use
                5. Add-on configuration
              3. SQL adapter
                1. Facts
                2. Architecture
                3. Features
                4. Query delegate
                5. References
                6. Free form query
                7. Similar add-ons
              4. Server push
                1. Installation
                2. How-to
                3. Example
        3. Twaattin improves!
          1. Twaattin application
          2. Timeline window
          3. New item handler
        4. Summary
      16. 8. Creating Custom Components
        1. Widget composition
          1. Manual composition
          2. Strategy for custom components
          3. Graphic composition
            1. Visual editor setup
            2. Visual editor use
              1. Position and size
            3. Limitations
              1. Restricted compatibility
              2. Top level element
              3. Rigid structure
              4. Limited embed capability
        2. GWT widget wrapping
          1. Vaadin GWT architecture
            1. Client side
              1. GWT and compilation
              2. Widget styling
              3. Example
            2. Server side
            3. Server client communication
              1. UIDL characteristics
              2. Object serialization
              3. Descending communication
              4. YouTube viewer example
            4. Client server communication
              1. Slider example
                1. Client wrapper
                2. Style
                3. Server component
        3. Componentized Twaattin
          1. Designing the component
          2. Updating Twaattin's code
            1. Tweet component
            2. Tweet label
            3. When label
            4. Timeline window
            5. Final touch
        4. Summary
      17. 9. Integration with Third-party Products
        1. Spring
          1. Inversion of Control and Dependency Injection
            1. Inversion of Control
            2. Dependency Injection
          2. Spring use-cases
          3. Prerequisites
            1. Downloading Spring
            2. IDE enhancements
          4. Design
            1. Bean factory and application context
            2. Vaadin application and servlet
            3. Requirements and specifications
          5. Code
            1. Servlet code
            2. Spring configuration
              1. Scope
          6. Additional thoughts
        2. Java EE 6
          1. Introduction
            1. Profiles
            2. Tomcat and the web profile
          2. Prerequisites
            1. Glassfish 3.1
              1. Glassfish download
              2. Glassfish installation
              3. Eclipse integration
          3. Code
            1. Servlet
            2. Application
            3. Window
        3. Hibernate
          1. Hibernate mappings
            1. Seeing is believing
              1. Job
              2. Person
          2. Hibernate container
            1. Container architecture
            2. Managing transactions
              1. Starting transaction
              2. Committing/rollbacking
                1. Committing filter
                2. Committing aspect
                3. Committing servlet
                4. Vaadin native approach
              3. Example session manager
              4. The application
            3. At last, the window
              1. Delete button
              2. Job select
              3. Main window
              4. Hibernate configuration
          3. Putting it all together
            1. Hibernate
            2. SLF4J
            3. HbnContainer
          4. Final notes
            1. Serialization exception
            2. Optimizations
            3. Rollback management
        4. Java Persistence API
        5. Summary
      18. 10. Beyond Application Servers
        1. Build tools
          1. Available tools
            1. Apache Ant
            2. Apache Maven
            3. Fragmentation
            4. Final choice
          2. Tooling
          3. Maven in Vaadin projects
            1. Mavenize a Vaadin project
            2. Vaadin support for Maven projects
          4. Mavenizing Twaattin
            1. Preparing the migration
            2. Enabling dependency management
            3. Finishing touches
              1. GWT build
              2. Cleaning up warning messages
              3. Optimizations
            4. Final POM
        2. Portals
          1. Portal, container, and portlet
          2. Choosing a platform
            1. Liferay
            2. GateIn
              1. Downloading and installation
              2. Preparing the platform
              3. Launch
          3. Tooling
          4. A simple portlet
            1. Creating a project
            2. Portlet project differences
              1. Portlet deployment descriptor
              2. Portal proprietary files
              3. Similarities
            3. Using the portlet in GateIn
              1. Deploying in GateIn
              2. Adding the portlet to a page
                1. Sign in
                2. Refresh portlets
                3. Add portlet
          5. Configuring GateIn for Vaadin
            1. Themes and widgetsets
              1. Serve files from the portal
              2. Serve files from an HTTP server
              3. Configure files location
          6. Advanced integration
            1. Restart and debug
            2. Handling portlet specifics
          7. Portlet development strategies
            1. Keep our portlet servlet-compatible
            2. Portal debug mode
            3. Updating a deployed portlet
          8. Integrating Twaattin
            1. Portlet deployment descriptor
            2. Web deployment descriptor
            3. Maven changes
              1. Dependency changes
              2. Multiplatform build
                1. Assembly descriptor
                2. Final POM
        3. OSGi
          1. Choosing a platform
            1. Glassfish
              1. Deploying bundles
                1. Prerequisites
                2. Telnet deployment
                3. File system deployment
                4. Web console deployment
          2. Tooling
          3. Vaadin OSGi use-cases
            1. Vaadin bundling
            2. Modularization
          4. Hello OSGi
            1. Making a bundle
            2. Export, deploy, run
            3. Correcting errors
              1. Application class
              2. Accessing the widgetset
          5. Integrating Twaattin
            1. Bundle plugin
            2. Multiplatform build
            3. Build and deploy
        4. Cloud
          1. Cloud offering levels
          2. State of the market
          3. Tooling
          4. Hello cloud
            1. Registration
            2. Cloud setup
            3. Application deployment
            4. Alternative deployment
          5. Integrating Twaattin
            1. Creating the datasource
            2. Using the datasource
            3. Finishing touches
        5. Summary
      19. Index