- Java 7
- NetBeans 7.3 (Java EE bundle)
- Glassfish 3.1.2.2 (Bundled with NetBeans)
- Vaadin 7
In NetBeans, create a new Web Application project (File -> New Project... or Ctrl + Shift + N) called Test:
Verify the Glassfish Server configuration (Window -> Services or Ctrl + 5).
Create a new library for Vaadin 7 (In the Test project, right-click Libraries -> Add Library..., then select Create)
From the Vaadin 7.0.1 bundle, I am including a minimal number of JAR files for the example that have been moved and renamed on my system to a user java library location.
In Vaadin 7, a UI is a viewport to a Vaadin application running in a web page. Create a new Java class MainUI that extends UI (File -> New File... or Ctrl + N).
Override the init() method of UI, adding a layout and user components to display Hello World!:
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
public class MainUI extends UI {
@Override
public void init(VaadinRequest request) {
VerticalLayout content = new VerticalLayout();
content.setSizeFull();
content.addComponent(new Label("Hello World!"));
getPage().setTitle("Hello World!"); // Web page title
setContent(content); // Layout component
}
}
To deploy the Vaadin application, create a deployment descriptor web.xml (File -> New File... or Ctrl + N).
The Vaadin servlet class is initialized using the MainUI class from above:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<display-name>Test</display-name>
<!-- Vaadin Configuration -->
<servlet>
<servlet-name>Vaadin 7</servlet-name>
<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
<init-param>
<param-name>UI</param-name>
<param-value>MainUI</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Vaadin 7</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Run the application (F6) and view your first Vaadin application at http://localhost:8080/Test.
We started small, but hopefully allowing you to scale fast. I recommend reading the Book of Vaadin as your next step.








