A nano project to start a Vaadin project. Perfect for Micro-UIs packed as fat jar in a docker image. This will be used in some of the tutorial implementations.
All tutorials are available under https://vaadin.com/tutorials
The target of this project is a minimal rampup time for a first hello world. Why we need one more HelloWorld? Well, the answer is quite easy. If you have to try something out, or you want to make a small POC to present something, there is no time and budget to create a demo project. You don´t want to copy paste all small things together. Here you will get a HelloWorld-Project that will give you all in a second.
Clone the repo and start editing the class VaadinApp
or BasicTestUIRunner
.
Nothing more.
This project will not use any additional maven plugin or technology.
Here we are using the plain meecrowave as Servlet-Container. http://openwebbeans.apache.org/meecrowave/index.html
But let´s start from the beginning.
The class BasicTestUIRunner
will ramp up the Container.
Here all the basic stuff is done. The start will init. a ServletContainer at port 8080.
If you want to use a random port, use randomHttpPort()
instead of setHttpPort(8080);
The WebApp will deployed as ROOT.war.
public class BasicTestUIRunner {
private BasicTestUIRunner() {
}
public static void main(String[] args) {
new Meecrowave(new Meecrowave.Builder() {
{
// randomHttpPort();
setHttpPort(8080);
setTomcatScanning(true);
setTomcatAutoSetup(false);
setHttp2(true);
}
})
.bake()
.await();
}
}
After this you can start the app invoking the main-method.
The UI itself is quite easy. There is only a button you can click. For every click, the counter will be increased. For more information about the routing (@Route(""")), have a look at the orig documentation https://vaadin.com/docs/v10/flow/routing/tutorial-routing-annotation.html
@Route("")
public class VaadinApp extends Composite<Div> implements HasLogger {
private final Button btnClickMe = new Button("click me");
private final Span lbClickCount = new Span("0");
private final VerticalLayout layout = new VerticalLayout(btnClickMe, lbClickCount);
private int clickcount = 0;
public VaadinApp() {
btnClickMe.addClickListener(event -> lbClickCount.setText(valueOf(++clickcount)));
//set the main Component
logger().info("setting now the main ui content..");
getContent().add(layout);
}
}
Happy Coding.
if you have any questions: ping me on Twitter https://twitter.com/SvenRuppert or via mail.