diff options
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/getting-started/chapter-getting-started.asciidoc | 2 | ||||
-rw-r--r-- | documentation/getting-started/getting-started-kotlin.asciidoc | 51 |
2 files changed, 53 insertions, 0 deletions
diff --git a/documentation/getting-started/chapter-getting-started.asciidoc b/documentation/getting-started/chapter-getting-started.asciidoc index 687029adaa..0d9f8f4d65 100644 --- a/documentation/getting-started/chapter-getting-started.asciidoc +++ b/documentation/getting-started/chapter-getting-started.asciidoc @@ -22,3 +22,5 @@ include::getting-started-maven.asciidoc[leveloffset=+2] include::getting-started-package.asciidoc[leveloffset=+2] include::getting-started-scala.asciidoc[leveloffset=+2] + +include::getting-started-kotlin.asciidoc[leveloffset=+2] diff --git a/documentation/getting-started/getting-started-kotlin.asciidoc b/documentation/getting-started/getting-started-kotlin.asciidoc new file mode 100644 index 0000000000..18eabaa695 --- /dev/null +++ b/documentation/getting-started/getting-started-kotlin.asciidoc @@ -0,0 +1,51 @@ +--- +title: Using Vaadin with Kotlin +order: 1100 +layout: page +--- + +[[getting-started.kotlin]] += Using Vaadin with Kotlin + +You can use Vaadin with the link:https://kotlinlang.org/[Kotlin] language as well. Kotlin offers +awesome tooling which includes a plugin for Intellij IDEA, Eclipse and Netbeans. +The plugin includes the possibility to convert any Java class to Kotlin, therefore the easiest way +is to generate the sample link:https://vaadin.com/maven[Java Vaadin Maven project] and +then convert the [filename]#MyUI# class to Kotlin, by pressing +kbd:[Ctrl+Alt+Shift+K]. The Kotlin plugin will convert the class and include Kotlin Maven plugin +to your [filename]#pom.xml#. + +The link:https://github.com/mvysny/karibu-dsl[Karibu-DSL] library offers a more Kotlin-like +API for Vaadin. The library will allow you to create +your UI in a hierarchical way. For more details please see +link:https://kotlinlang.org/docs/reference/type-safe-builders.html[Kotlin Type-Safe Builders]. +There is a link:https://github.com/mvysny/karibu-helloworld-application[Karibu Helloworld Application] +sample which demonstrates this technique. It is a standard Gradle project, thus you +only need to `git clone` the project and open it in your IDE. The hierarchical code looks as follows: + +[source, kotlin] +---- +@Theme("mytheme") +class MyUI : UI() { + + private lateinit var layout: VerticalLayout + + @Override + override fun init(vaadinRequest: VaadinRequest) { + layout = verticalLayout { + val name = textField { + caption = "Type your name here:" + } + button("Click Me", { + println("Thanks ${name.value}, it works!") + layout.label("Thanks ${name.value}, it works!") + }) + } + } +} +---- + +It is also possible to use Kotlin to access your database, allowing you to build full-blown +web applications. For details please see the +link:http://www.vaadinonkotlin.eu/[Vaadin-on-Kotlin] library. Just follow +the Getting Started tutorial there - the tutorial will guide you step-by-step. |