VaadinNotes » History » Revision 45
« Previous |
Revision 45/125
(diff)
| Next »
Andreas Kohlbecker, 10/27/2016 05:29 PM
Vaadin Development Resources¶
Vaadin is an open source Web application framework for rich Internet applications. In contrast to JavaScript libraries and browser-plugin based solutions, it features a server-side architecture, which means that the majority of the logic runs on the servers. Ajax technology is used at the browser-side to ensure a rich and interactive user experience. On the client-side Vaadin is built on top of and can be extended with Google Web Toolkit.
This page holds information and resources for developing with the GWT-based Vaadin-Framework. For general information to this framework see: https://vaadin.com/faq
(quoted from Wikipedia:https://en.wikipedia.org/wiki/Vaadin, the free encyclopedia)
- Table of contents
- Vaadin Development Resources
General Structure of Vaadin¶
The Vaadin architecture can be split very roughly into client and server side.
The server side holds all the business logic and services as well as the standard java vaadin components, which will be translated into JavaScript later on.
The client side incorporates the GWT-part as well as client side specific JavaScript code, to do some more dynamic manipulation on the browser side.
All Vaadin Components are written in plain Java. There is no need to program in JavaScript or even HTML. This all will be compiled by the framework. See the next section for supported browsers.
Browser compatibility¶
Vaadin 7 supports the following browsers:
Android 2.3 or newer
Google Chrome 23 or newer
Internet Explorer 8 or newer
iOS 5,6,7 or newer
Mozilla Firefox 17 or newer
Opera 12 or newer
Safari 6 or newer
NOTE: From release 7.2+ all permutations have been merged into a single one - refer #13274
Development Environment Setup¶
To start with you will need to install the Eclipse IDE. Currently, the versions of Eclipse tested with this setup include :
- Eclipse 4.4.1 Luna
You will also need to install Maven 3.x.x
Since we will be using Jetty to run the project as web appplication, you will also need to install Jetty Integration.
If you want to use the RunJettyRun plugin make sure you are using version 9.0.0+ which is available via the nightly update site - http://run-jetty-run.googlecode.com/svn/trunk/updatesite-nightly. The reason for the specific version of Jetty is due to the dependency on Servlet 3.0+ API which is used in the project.
The next step is to install the Vaadin Plugin for Eclipse - section 2.4.2 from the Book of Vaadin. This plugin provides tools for compiling widgetsets, creating Vaadin specific objects and designing components using the included Vaadin Visual Designer.
Checkout the cdm-vaadin project with
svn co http://dev.e-taxonomy.eu/svn/trunk/cdm-vaadin
and build the project with
mvn clean install
For setting up the Eclipse project run,
mvn eclipse:eclipse
Startup Eclipse and import the above project.
Import the cdm-vaadin jetty launch configuration in Eclipse by selecting File->Import->Launch Configurations and choosing the cdm-vaadin.launch file in the ide/eclipse directory.
Launch the cdm-vaadin launch configuration and check if http://localhost:8080/cdm-vaadin/app-test/navi is available.
cdm-vaadin project¶
The cdm-vaadin project is a stand-alone war Eclipse / Maven project, which includes cdmlib dependencies allowing it to function as a full-fledged web application. This allows for testing the vaadin framework with the cdmlib. This project itself is not a target for deployment as a webapp, but is integrated into the cdmlib-remote-webapp project as described below.
Vaadin specific maven goals include,
vaadin:clean vaadin:resources vaadin:update-theme vaadin:update-widgetset vaadin:compile-theme vaadin:compile
cdm-vaadin project integration with the cdmlib-remote-webapp¶
To Be Done
Servlet Deployment Configuration¶
With Servlet 3.0+ all configuration other wise declared in web.xml can now be declared using annotations in specfic Java classes. The servlet deployment configuration for the project consists of,
Web Application Initializer : consists currently of two main parts, both of which are declared in the 'eu.etaxonomy.cdm.vaadin.CdmAppInitializer' class.
- ContextLoaderListener, a servlet context listener that associates a Spring application context with your servlet context and makes it accessible to other Spring classes. Typically this is defined via an applicationContext.xml file that sits in WEB-INF.
- DispatcherServlet, a regular Java servlet that Spring provides. Each such servlet has its own Spring application context - distinct from, though a "child" of, the one mentioned above associated with the ContextLoaderListener. If your servlet is named foobar then the default XML file name is foobar-servlet.xml.
Servlet Mapping : primarily connects a Vaadin UI class to a VaadinServlet class, with 'init-param' style annotations. Any of the UI classes in the project can be looked up for examples of this configuration.
NOTE: The 'Web Application Initializer' part of the configuration does not yet work for the moment (refer #4527) and is set for now in the web.xml.
Vaadin Components¶
Vaadin AddOn's¶
The official Vaadin website hosts a directory of all available AddOn's http://vaadin.com/directory.
In order to add an extension to your project add the maven dependencies to your pom file and run
mvn eclipse:eclipse
the needed libraries will be downloaded. Check if the libraries are added in you IDE specific dependency tree. Sometimes it can be necessary to clean the whole project and build it again with
mvn clean install
Developer Notes¶
For a general overview on how to develope with Vaadin, you can refer to the online version of the Book Of Vaadin Some of the important aspects are listed here.
Creating a server-side UI¶
Normally, you need to:
extend the UI class
build an initial UI from components
define event listeners to implement the UI logic
Optionally, you can also:
set a custom theme for the UI
bind components to data
bind components to resources
Model-View-Presenter Pattern¶
The pattern is described in section 11.10.2 #advanced.architecture.mvp of the Book of Vaadin. An example of the pattern in the project is the 'eu.etaxonomy.cdm.vaadin.view.AuthenticationView' class.
CDM Library Specific Development¶
This section lists the important CDM specific development issues to integrating Vaadin.
Managing Sessions¶
The strategies to solve the lazy loading problem and in more general to manage sessions properly include,
- *Conversational Sessions : * which essentially involves linking any UI which requires long running sessions to a 'eu.etaxonomy.cdm.vaadin.servlet.CdmVaadinConversationalServlet'. The servlet creates an instance of the ConversationHolder when a VaadinSession is initialized and binds it on every service call, ensuring that a single hibernate session is attached to a corresponding vaadin session.*NOTE: * One major issue with this strategy is the bug (#4528) which flushes the entire session even if a save / saveOrUpdate call is made on a single CDM entity. This implies that this strategy is safe to use only in 'session-save' UIs and not 'auto-save' UIs.
Exposing CDM Application Context¶
This issue relates to the problem that in the Vaadin framework it is not possible to autowire beans from the underlying application context as Vaadin prevents this possibility. To overcome this problem, a singleton helper class eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper has been written to retrieve the beans given the bean name.
Miscellaneous Notes¶
- Currently the Server Push functionality of Vaadin has been disabled (by commenting out the relevant section in the pom file)
Conventions & Policies¶
Vaadin Security¶
Updated by Andreas Kohlbecker over 7 years ago · 45 revisions