Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

Making the demo app more upto date #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ The topics that are covered in this tutorial project:
* Register VaadinServiceInitListener via CDI Observer
* Flow template within CDI
* Use I18N in CDI
* Extending servlet

## Running the project from command line

Run `mvn clean package tomee:run` in the project root directory. After the server has started point your browser to [http://localhost:8080](http://localhost:8080) to see the resulting application.

or

Run ``mvn clean package wildfly:run` in the project root directory. After the server has started point your browser to [http://localhost:8080/cdi.tutorial-1.0.0-SNAPSHOT/](http://localhost:8080/cdi.tutorial-1.0.0-SNAPSHOT/) to see the resulting application.

13 changes: 13 additions & 0 deletions frontend/example-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { html, PolymerElement } from '@polymer/polymer';

export class ExampleTemplate extends PolymerElement {
static get is() {
return 'example-template'
}

static get template() {
return html`<span>[[message]]</span>`;
}
}

customElements.define(ExampleTemplate.is, ExampleTemplate);
40 changes: 28 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
<webapp.directory>src/main/webapp</webapp.directory>

<!-- Dependencies -->
<vaadin.version>10.0.3</vaadin.version>
<flow.maven.plugin.version>1.0.3</flow.maven.plugin.version>
<vaadin.version>14.8.14</vaadin.version>
</properties>

<pluginRepositories>
Expand Down Expand Up @@ -56,12 +55,11 @@
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-cdi</artifactId>
<version>10.0.0.beta1</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<version>8.0</version>
<scope>provided</scope>
</dependency>

Expand All @@ -74,6 +72,30 @@

<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<configuration>
<pnpmEnable>true</pnpmEnable>
<requireHomeNodeExec>true</requireHomeNodeExec>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.0.Final</version>
<configuration>
<version>15.0.0.Final</version>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
Expand Down Expand Up @@ -121,18 +143,12 @@
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>flow-maven-plugin</artifactId>
<version>${flow.maven.plugin.version}</version>
<artifactId>vaadin-maven-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-production-files</goal>
<goal>package-for-production</goal>
<goal>build-frontend</goal>
</goals>
<configuration>
<transpileOutputDirectory>${webapp.directory}</transpileOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/vaadin/cdi/tutorial/ExampleTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.vaadin.cdi.tutorial;

import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.HtmlImport;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.polymertemplate.PolymerTemplate;
import com.vaadin.flow.templatemodel.TemplateModel;
import org.vaadin.cdi.tutorial.ExampleTemplate.ExampleModel;
Expand All @@ -27,14 +27,13 @@
* Simple template example.
*/
@Tag("example-template")
@HtmlImport("frontend://ExampleTemplate.html")
@JsModule("./example-template.js")
public class ExampleTemplate extends PolymerTemplate<ExampleModel> {

/**
* Template model which defines the single "name" property.
*/
public interface ExampleModel extends TemplateModel {

void setMessage(String message);
}

Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/vaadin/cdi/tutorial/MyServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.vaadin.cdi.tutorial;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;

import com.vaadin.cdi.CdiVaadinServlet;
import com.vaadin.flow.server.CustomizedSystemMessages;
import com.vaadin.flow.server.SystemMessages;
import com.vaadin.flow.server.SystemMessagesInfo;
import com.vaadin.flow.server.SystemMessagesProvider;

@WebServlet(urlPatterns = {"/*","/frontend/*"}, asyncSupported = true)
public class MyServlet extends CdiVaadinServlet {

@Override
protected void servletInitialized() throws ServletException
{
super.servletInitialized();

this.getService().setSystemMessagesProvider(new SystemMessagesProvider() {

@Override
public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
CustomizedSystemMessages messages = new CustomizedSystemMessages();
messages.setSessionExpiredCaption("Sitzung abgelaufen");
messages.setSessionExpiredMessage("Bitte notieren Sie ungespeicherte Daten und <u>klicken Sie hier</u> oder drücken Sie die ESC-Taste...");
messages.setSessionExpiredNotificationEnabled(true);
messages.setInternalErrorCaption("Kommunikationsfehler");
messages.setInternalErrorMessage("Bitte notieren Sie ungespeicherte Daten und <u>klicken Sie hier</u> oder drücken Sie die ESC-Taste...");
messages.setInternalErrorNotificationEnabled(true);
messages.setCookiesDisabledCaption("Cookies sind abgeschaltet");
messages.setCookiesDisabledMessage("Diese Anwendung benötigt Cookies, um korrekt zu funktionieren.<br>Bitte schalten Sie Cookies in Ihrem Browser ein und <u>klicken Sie hier</u> oder drücken Sie die ESC-Taste...");
messages.setCookiesDisabledNotificationEnabled(true);
messages.setInternalErrorCaption("Interner Fehler");
messages.setInternalErrorMessage("Informieren Sie Ihren Anwendungsbetreuer.<br/>Bitte notieren Sie ungespeicherte Daten und <u>klicken Sie hier</u> oder drücken Sie die ESC-Taste...");
messages.setInternalErrorNotificationEnabled(true);
return messages;
}
});
}
}
3 changes: 1 addition & 2 deletions src/main/java/org/vaadin/cdi/tutorial/RootComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ public RootComponent(UiGreeter uiGreeter, ExampleTemplate template) {
getTranslation("root.navigate_to_component"),
ParentView.class);

Style linkStyle = link.getElement().getStyle();
Style linkStyle = link.getStyle();
linkStyle.set("display", "block");
linkStyle.set("margin-bottom", "10px");

add(greeting, button, link, template);
add(template);
}

@Override
Expand Down
35 changes: 0 additions & 35 deletions src/main/webapp/frontend/ExampleTemplate.html

This file was deleted.