-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demo step by step vaadin 7 app with JPA backend
- Loading branch information
0 parents
commit 582dd9d
Showing
13 changed files
with
13,537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
contacts | ||
============== | ||
|
||
Template for a simple Vaadin application that only requires a Servlet 3.0 container to run. | ||
|
||
|
||
Workflow | ||
======== | ||
|
||
To compile the entire project, run "mvn install". | ||
|
||
To run the application, run "mvn jetty:run" and open http://localhost:8080/ . | ||
|
||
To produce a deployable production mode WAR: | ||
- change productionMode to true in the servlet class configuration (nested in the UI class) | ||
- run "mvn clean package" | ||
- test the war file with "mvn jetty:run-war" | ||
|
||
Client-Side compilation | ||
------------------------- | ||
|
||
The generated maven project is using an automatically generated widgetset by default. | ||
When you add a dependency that needs client-side compilation, the maven plugin will | ||
automatically generate it for you. Your own client-side customisations can be added into | ||
package "client". | ||
|
||
Debugging client side code | ||
- run "mvn vaadin:run-codeserver" on a separate console while the application is running | ||
- activate Super Dev Mode in the debug window of the application | ||
|
||
Developing a theme using the runtime compiler | ||
------------------------- | ||
|
||
When developing the theme, Vaadin can be configured to compile the SASS based | ||
theme at runtime in the server. This way you can just modify the scss files in | ||
your IDE and reload the browser to see changes. | ||
|
||
To use the runtime compilation, open pom.xml and comment out the compile-theme | ||
goal from vaadin-maven-plugin configuration. To remove a possibly existing | ||
pre-compiled theme, run "mvn clean package" once. | ||
|
||
When using the runtime compiler, running the application in the "run" mode | ||
(rather than in "debug" mode) can speed up consecutive theme compilations | ||
significantly. | ||
|
||
It is highly recommended to disable runtime compilation for production WAR files. | ||
|
||
Using Vaadin pre-releases | ||
------------------------- | ||
|
||
If Vaadin pre-releases are not enabled by default, use the Maven parameter | ||
"-P vaadin-prerelease" or change the activation default value of the profile in pom.xml . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.vaadin.stepbystep</groupId> | ||
<artifactId>contacts</artifactId> | ||
<packaging>war</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>contacts</name> | ||
|
||
<prerequisites> | ||
<maven>3</maven> | ||
</prerequisites> | ||
|
||
<properties> | ||
<vaadin.version>7.7.0</vaadin.version> | ||
<vaadin.plugin.version>7.7.0</vaadin.plugin.version> | ||
<jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<!-- If there are no local customisations, this can also be "fetch" or "cdn" --> | ||
<vaadin.widgetset.mode>local</vaadin.widgetset.mode> | ||
<deltaspike.version>1.5.2</deltaspike.version> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>vaadin-addons</id> | ||
<url>http://maven.vaadin.com/vaadin-addons</url> | ||
</repository> | ||
<repository> | ||
<id>vaadin-snapshots</id> | ||
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> | ||
<releases> | ||
<enabled>false</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-bom</artifactId> | ||
<version>${vaadin.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-server</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-push</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-client-compiled</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-themes</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-cdi</artifactId> | ||
<version>1.0.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.deltaspike.core</groupId> | ||
<artifactId>deltaspike-core-api</artifactId> | ||
<version>${deltaspike.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.deltaspike.core</groupId> | ||
<artifactId>deltaspike-core-impl</artifactId> | ||
<version>${deltaspike.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.deltaspike.modules</groupId> | ||
<artifactId>deltaspike-data-module-api</artifactId> | ||
<version>${deltaspike.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.deltaspike.modules</groupId> | ||
<artifactId>deltaspike-data-module-impl</artifactId> | ||
<version>${deltaspike.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<version>7.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.vaadin.stepbystep</groupId> | ||
<artifactId>person-service</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>2.6</version> | ||
<configuration> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
<!-- Exclude an unnecessary file generated by the GWT compiler. --> | ||
<packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-maven-plugin</artifactId> | ||
<version>${vaadin.plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>update-theme</goal> | ||
<goal>update-widgetset</goal> | ||
<goal>compile</goal> | ||
<!-- Comment out compile-theme goal to use on-the-fly theme compilation --> | ||
<goal>compile-theme</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<!-- Clean up also any pre-compiled themes --> | ||
<configuration> | ||
<filesets> | ||
<fileset> | ||
<directory>src/main/webapp/VAADIN/themes</directory> | ||
<includes> | ||
<include>**/styles.css</include> | ||
<include>**/styles.scss.cache</include> | ||
</includes> | ||
</fileset> | ||
</filesets> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- The Jetty plugin allows us to easily test the development build by | ||
running jetty:run on the command line. --> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>${jetty.plugin.version}</version> | ||
<configuration> | ||
<scanIntervalSeconds>2</scanIntervalSeconds> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<!-- Vaadin pre-release repositories --> | ||
<id>vaadin-prerelease</id> | ||
<activation> | ||
<activeByDefault>false</activeByDefault> | ||
</activation> | ||
|
||
<repositories> | ||
<repository> | ||
<id>vaadin-prereleases</id> | ||
<url>http://maven.vaadin.com/vaadin-prereleases</url> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>vaadin-prereleases</id> | ||
<url>http://maven.vaadin.com/vaadin-prereleases</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/vaadin/stepbystep/contacts/ContactsUI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.vaadin.stepbystep.contacts; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.inject.Inject; | ||
import javax.servlet.annotation.WebServlet; | ||
|
||
import org.vaadin.stepbystep.person.backend.PersonService; | ||
|
||
import com.vaadin.annotations.Theme; | ||
import com.vaadin.annotations.VaadinServletConfiguration; | ||
import com.vaadin.cdi.CDIUI; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.server.VaadinServlet; | ||
import com.vaadin.ui.UI; | ||
|
||
/** | ||
* This UI is the application entry point. A UI may either represent a browser window | ||
* (or tab) or some part of a html page where a Vaadin application is embedded. | ||
* <p> | ||
* The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be | ||
* overridden to add component to the user interface and initialize non-component functionality. | ||
*/ | ||
@Theme("mytheme") | ||
@CDIUI("") | ||
public class ContactsUI extends UI { | ||
|
||
@Inject | ||
PersonService service; | ||
|
||
@PostConstruct | ||
void load() { | ||
setContent(new ContactsView(service)); | ||
} | ||
|
||
@Override | ||
protected void init(VaadinRequest vaadinRequest) { | ||
|
||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/org/vaadin/stepbystep/contacts/ContactsView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.vaadin.stepbystep.contacts; | ||
|
||
import org.vaadin.stepbystep.person.backend.Person; | ||
import org.vaadin.stepbystep.person.backend.PersonService; | ||
|
||
import com.vaadin.data.util.BeanItemContainer; | ||
import com.vaadin.server.Sizeable.Unit; | ||
import com.vaadin.ui.CustomComponent; | ||
import com.vaadin.ui.Grid; | ||
import com.vaadin.ui.HorizontalSplitPanel; | ||
|
||
public class ContactsView extends CustomComponent { | ||
|
||
private BeanItemContainer<Person> container; | ||
private Grid grid; | ||
|
||
public static final String PROPERTY_FIRSTNAME = "firstname"; | ||
public static final String PROPERTY_LASTNAME = "lastname"; | ||
public static final String PROPERTY_EMAIL = "email"; | ||
public static final String PROPERTY_DOB = "birthDate"; | ||
public static final String PROPERTY_NOTES = "notes"; | ||
|
||
public ContactsView(PersonService service) { | ||
|
||
service.loadData(); | ||
|
||
container = new BeanItemContainer<>(Person.class, service.getEntries()); | ||
|
||
grid = new Grid(container); | ||
grid.setSizeFull(); | ||
grid.removeAllColumns(); | ||
|
||
grid.addColumn(PROPERTY_FIRSTNAME); | ||
grid.getColumn(PROPERTY_FIRSTNAME).setHeaderCaption("First Name"); | ||
grid.addColumn(PROPERTY_LASTNAME); | ||
grid.getColumn(PROPERTY_LASTNAME).setHeaderCaption("Last Name"); | ||
|
||
HorizontalSplitPanel splitter = new HorizontalSplitPanel(); | ||
splitter.setSplitPosition(30, Unit.PERCENTAGE); | ||
|
||
splitter.setFirstComponent(grid); | ||
splitter.setSecondComponent(new PersonViewImpl(grid, service)); | ||
|
||
setSizeFull(); | ||
setCompositionRoot(splitter); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/vaadin/stepbystep/contacts/PersonViewDesign.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.vaadin.stepbystep.contacts; | ||
|
||
import com.vaadin.annotations.AutoGenerated; | ||
import com.vaadin.annotations.DesignRoot; | ||
import com.vaadin.ui.Button; | ||
import com.vaadin.ui.DateField; | ||
import com.vaadin.ui.HorizontalLayout; | ||
import com.vaadin.ui.Image; | ||
import com.vaadin.ui.TextArea; | ||
import com.vaadin.ui.TextField; | ||
import com.vaadin.ui.declarative.Design; | ||
|
||
/** | ||
* !! DO NOT EDIT THIS FILE !! | ||
* | ||
* This class is generated by Vaadin Designer and will be overwritten. | ||
* | ||
* Please make a subclass with logic and additional interfaces as needed, | ||
* e.g class LoginView extends LoginDesign implements View { } | ||
*/ | ||
@DesignRoot | ||
@AutoGenerated | ||
@SuppressWarnings("serial") | ||
public class PersonViewDesign extends HorizontalLayout { | ||
protected Image picture; | ||
protected TextField firstname; | ||
protected TextField lastname; | ||
protected TextField email; | ||
protected DateField dateOfBirth; | ||
protected TextArea notes; | ||
protected Button save; | ||
protected Button edit; | ||
protected Button cancel; | ||
protected Button delete; | ||
|
||
public PersonViewDesign() { | ||
Design.read(this); | ||
} | ||
} |
Oops, something went wrong.