• Stars
    star
    177
  • Rank 209,166 (Top 5 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created about 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Writing full-stack statically-typed web apps on JVM at its simplest

Powered By Vaadin on Kotlin Join the chat at https://gitter.im/vaadin/vaadin-on-kotlin GitHub tag Maven Central Build Status

Welcome to Vaadin-On-Kotlin

Vaadin-on-Kotlin is a web-application framework that includes everything needed to create database-backed web applications. Please see the official documentation at www.vaadinonkotlin.eu.

Vaadin-on-Kotlin does not enforce you to use Model-View-Controller (MVC), Dependency Injection (DI) nor Service-Oriented Architecture (SOA). It by default does not use Spring nor JavaEE. Instead, Vaadin-on-Kotlin focuses on simplicity.

The View layer leverages component-oriented programming as offered by the Vaadin framework. Vaadin offers powerful components which are built on AJAX; programming in Vaadin resembles programming in a traditional client-side framework such as JavaFX or Swing.

The database access layer is covered by the vok-orm library. vok-orm allows you to present the data from database rows as objects and embellish these data objects with business logic methods. Using vok-orm is the recommended approach to access SQL databases. Of course, you may decide not to use vok-orm and integrate with NoSQL instead, or use JPA and/or Hibernate.

Everything is combined with the conciseness of the Kotlin programming language, which makes Vaadin-on-Kotlin a perfect starting point for beginner programmers. And Kotlin is statically-typed, so you can always Ctrl+Click on a code and learn how it works under the hood!

For a Getting Started guide please see the official documentation at www.vaadinonkotlin.eu/.

Getting Started

  1. Please install Java 17 JDK and git client if you haven't yet.

  2. Then, at the command prompt, just type in:

    git clone https://github.com/mvysny/vok-helloworld-app
    cd vok-helloworld-app
    ./gradlew clean build web:appRun
  3. Using a browser, go to http://localhost:8080 and you'll see: "Yay! You're on Vaadin-on-Kotlin!"

  4. Follow the guidelines to start developing your application. You may find the following resources handy:

  5. For easy development, we encourage you to edit the project sources in Intellij IDEA; the Community Edition is enough.

Example project

A more polished example application which you can inspire from. Just type this into your terminal:

git clone https://github.com/mvysny/vaadin-on-kotlin
cd vaadin-on-kotlin
./gradlew vok-example-crud:run

The web app will be running at http://localhost:8080.

For more information check out the vok-example-crud module.

Vaadin Example project

Head to Beverage Buddy VoK for the standalone example project.

Run the example application from Intellij IDEA Community

  1. In Intellij IDEA, open the project simply by opening the build.gradle file, and then selecting "Open as Project".
  2. To run the application from IDEA, just open Gradle tab, select vok-example-crud-vokdb / Tasks / gretty / appRun, right-click and select Debug. The web app will be running at http://localhost:8080.

If you have the Intellij IDEA Ultimate version, we recommend you to use Tomcat for development, since it offers better code hot-redeployment:

  1. Open the project in IDEA
  2. Launch the vok-example-crud-vokdb WAR in Tomcat as described here: https://kotlinlang.org/docs/tutorials/httpservlets.html

Contributing

We encourage you to contribute to Vaadin-on-Kotlin! Join us and discuss at Vaadin Forums: Miscellaneous.

Trying to report a possible security vulnerability in Vaadin-on-Kotlin? Please use Vaadin Bug Tracker.

For general Vaadin-on-Kotlin bugs, please use the Vaadin-on-Kotlin Github Issue Tracker.

Modules

Vaadin-on-Kotlin consists of several modules which provides you with handy functionality. To include the modules into your project, you simply add appropriate Gradle jar dependencies to your build.gradle.

Every module contains a description of what exactly the module does, when you should use it and when it might be better to use something else.

The list of modules:

  • vok-framework - the very core of Vaadin-on-Kotlin which contains machinery for developing VoK plugins, and also the means to bootstrap/teardown the VoK runtime. Always included in your project when you build your app with VoK.
  • vok-util-vaadin - when you want to have additional support for Vaadin. You typically include this module when you build your Vaadin-based app with VoK.
  • vok-framework-vokdb - when you want to have additional support for Vaadin and the support for the database using the recommended approach. Includes vok-util-vaadin and vok-db.
  • vok-rest - when you want to expose data from your VoK app to other REST-consuming clients.
  • vok-rest-client - when you want to consume data in your VoK app from other REST servers.
  • vok-db - Provides access to the database; uses VoK-ORM
  • vok-security - provides basic security support. The documentation there explains the basics and provides links to sample projects.

Code Examples

Easy database transactions:

vok-orm:

button("Save", { db { person.save() } })

See vok-orm for an explanation on how this works.

Prepare your database

Simply use Flyway: write Flyway scripts, add a Gradle dependency:

compile 'org.flywaydb:flyway-core:7.1.1'

and introduce a context listener, to auto-update your database to the newest version before your app starts:

@WebListener
class Bootstrap: ServletContextListener {
    override fun contextInitialized(sce: ServletContextEvent?) {
        VaadinOnKotlin.init()
        val flyway = Flyway()
        flyway.dataSource = VaadinOnKotlin.getDataSource()
        flyway.migrate()
    }
}

Please scroll below for more details.

Defining UI DSL-style

verticalLayout {
  formLayout {
    isSpacing = true
    textField("Name:") {
      focus()
    }
    textField("Age:")
  }
  horizontalLayout {
    w = 100.perc
    isSpacing = true
    button("Save") {
      onLeftClick { okPressed() }
      setPrimary()
    }
  }
}

Simple popups

popupView("Details") {
  verticalLayout {
    formLayout { ... }
    button("Close", { isPopupVisible = false })
  }
}

vok-orm-based grid is a breeze

Support for sorting and filtering out-of-the-box:

grid<User>(dataProvider = Person.dataProvider) {
  isExpand = true
  
  val filterBar = appendHeaderRow().asFilterBar(this)

  columnFor(User::id) {
      filterBar.forField(NumberRangePopup(), this).inRange()
  }
  columnFor(User::username) {
      filterBar.forField(TextField(), this).ilike()
  }
  columnFor(User::roles) {
      filterBar.forField(TextField(), this).ilike()
  }
  columnFor(User::hashedPassword)
  addButtonColumn(VaadinIcon.EDIT, "edit", { createOrEditUser(it) }) {}
  addButtonColumn(VaadinIcon.TRASH, "delete", { it.delete(); refresh() }) {}
}

Advanced syntax

Keyboard shortcuts via operator overloading

import com.github.mvysny.karibudsl.v8.ModifierKey.Alt
import com.github.mvysny.karibudsl.v8.ModifierKey.Ctrl
import com.vaadin.event.ShortcutAction.KeyCode.C

button("Create New Person (Ctrl+Alt+C)") {
  onLeftClick { ... }
  clickShortcut = Ctrl + Alt + C
}

Width/height

button {
  icon = ...
  w = 48.px
  h = 50.perc
}
if (button.w.isFillParent) { ... }

Further Links

License

Licensed under the MIT License.

Copyright (c) 2017-2018 Martin Vysny

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

karibu-dsl

Kotlin Vaadin extensions and DSL
Kotlin
104
star
2

karibu-testing

Vaadin Server-Side Browserless Containerless Unit Testing
Kotlin
95
star
3

aedict

Original Aedict 2 source codes
Java
38
star
4

vaadin-kotlin-pwa

Vaadin Kotlin PWA - A Task List demo
Kotlin
24
star
5

vok-orm

Mapping rows from a SQL database to POJOs in its simplest form
Kotlin
22
star
6

gphoto2-java

Automatically exported from code.google.com/p/gphoto2-java
Java
22
star
7

dynatest

Simplest & Powerful Testing Framework For Kotlin. No annotations!
Kotlin
22
star
8

karibu-helloworld-application

Karibu-DSL HelloWorld application in Vaadin
Kotlin
21
star
9

beverage-buddy-vok

Simple Example Web Application for Vaadin Flow
Kotlin
19
star
10

slf4j-handroid

Android logging done right
Java
17
star
11

photocloud-frame-slideshow

Android Digital Photo Frame
13
star
12

vaadin-boot

Boots your Vaadin app in embedded Jetty from your main() method quickly and easily
Java
12
star
13

vaadin-quarkus

Vaadin 14 app running on Quarkus
Java
9
star
14

vaadin-boot-example-gradle

Vaadin with Embedded Jetty using Gradle
Java
8
star
15

vaadin14-boot-example-maven

Vaadin 14 npm with Embedded Jetty Demo using Maven
Java
7
star
16

vok-helloworld-app

A very simple Vaadin-on-Kotlin Vaadin 10 HelloWorld app which you start off when building your own apps
Kotlin
7
star
17

vok-security-demo

Vaadin-on-Kotlin Security Authentication + Authorization Demo for Vaadin
Kotlin
6
star
18

ktgpio-example-app

Kotlin/Native example app using ktgpio to turn GPIO Raspberry PI pins on and off
Kotlin
6
star
19

vaadin-coroutines-demo

A Kotlin Coroutines Demo for the Vaadin Web Framework
Kotlin
6
star
20

vok-helloworld-app-v8

A very simple Vaadin-on-Kotlin HelloWorld app which you start off when building your own apps
Kotlin
4
star
21

vaadin14-boot-example-gradle

Vaadin 14 npm+webpack with Embedded Jetty using Gradle
Java
4
star
22

karibu-tools

The Vaadin Missing Utilities
Kotlin
3
star
23

suckless-ascii-profiler

An embedded profiler which you start and stop at will, and it will dump the profiling info into the console
Kotlin
3
star
24

kotlin-unsigned-jvm

Utilities for working with unsigned values in Kotlin/JVM
Kotlin
3
star
25

bookstore-vok

A Bookstore Vaadin Example Ported to Vaadin-on-Kotlin
Kotlin
3
star
26

electricity-price-calculator

Kotlin
2
star
27

karibu8-helloworld-application

A very simple Vaadin 8 Karibu-DSL-based application
Kotlin
2
star
28

beverage-buddy-jooq

Simple Example Web Application for Vaadin Flow
Kotlin
2
star
29

karibu-migration

Aids migration from Vaadin 8 to Vaadin 14+
Kotlin
2
star
30

vaadin10-sqldataprovider-example

Demoes a SQLDataProvider and a Filter Bar for Vaadin 10 Grid
Java
2
star
31

failover-vaadin

A Vaadin Add-on which automatically performs browser-side fail-over. If the connection to the primary server is lost, the browser will automatically redirect itself to a fallback/spare server of your choosing.
Java
2
star
32

vaadin-groovy-builder

Building Vaadin UIs in Groovy pleasantly with DSL
Groovy
2
star
33

dialogheaderbar

Experimental Dialog Header Bar for Vaadin 14 Dialog
Java
2
star
34

ev-fi

Electric Vehicles in Finland
SCSS
1
star
35

karibu-helloworld-application-maven

Karibu-DSL HelloWorld application in Vaadin, Maven-based
Kotlin
1
star
36

vaadin-boot-example-maven

Vaadin 23 running in Embedded Jetty
Java
1
star
37

vaadin-loom

Toying with Project Loom and Vaadin
Java
1
star
38

solar-controller-client

Communicates with a solar controller (Renogy Rover) over RS232/USB and retrieves statistics
Kotlin
1
star
39

playwright-perftest-vaadin

Performance Testing Vaadin apps with Microsoft Playwright
Java
1
star
40

mvysny.github.io

The https://mvysny.github.io blog sources
SCSS
1
star
41

testbench-simplest-demo-14

The TestBench simplest demo for Vaadin 14, also uses Karibu-Testing
Java
1
star
42

vaadin-quarkus-skeleton-starter

A Vaadin Skeleton Starter app which runs Vaadin in Quarkus
Java
1
star
43

webmon

A tiny embeddable JVM monitoring tool
Java
1
star
44

shepherd

Build & run apps automatically
Shell
1
star
45

vaadin-simple-security

Very simple security framework for Vaadin
Java
1
star
46

dirutils

Android File and Directory utilities which do not suck
Java
1
star
47

shepherd-java-client

Vaadin Shepherd Java Client
Kotlin
1
star
48

vaadin8-sqldataprovider-example

Demoes a SQLDataProvider and a Filter Bar for Vaadin 8 Grid
Java
1
star