1
0
Fork
You've already forked kmultipage
0
No description
  • Kotlin 97.8%
  • JavaScript 1.4%
  • HTML 0.8%
2026年04月21日 08:25:20 +02:00
.idea Reads POST parameters using a ParametersReader 2026年03月07日 07:39:08 +01:00
adapters/kmultipage-ktor Changed copyright header on all files 2026年03月08日 07:44:31 +01:00
artwork/logos Added more icon svgs 2026年01月14日 11:58:21 +01:00
docs Changed copyright header on all files 2026年03月08日 07:44:31 +01:00
examples Changed copyright header on all files 2026年03月08日 07:44:31 +01:00
gradle/wrapper Initial Import to CodeBerg 2025年12月03日 10:13:57 +01:00
icons Changed copyright header on all files 2026年03月08日 07:44:31 +01:00
kmultipage More input elements 2026年04月21日 08:25:20 +02:00
kmultipage-tests More input elements 2026年04月21日 08:25:20 +02:00
.gitignore Initial Import to CodeBerg 2025年12月03日 10:13:57 +01:00
build.gradle.kts Simple forms work 2025年12月10日 11:54:57 +01:00
find_unlicensed.sh First version of documentation running... 2025年12月04日 16:21:04 +01:00
gradle.properties Initial Import to CodeBerg 2025年12月03日 10:13:57 +01:00
gradlew Initial Import to CodeBerg 2025年12月03日 10:13:57 +01:00
gradlew.bat Initial Import to CodeBerg 2025年12月03日 10:13:57 +01:00
LICENSE.txt Initial Import to CodeBerg 2025年12月03日 10:13:57 +01:00
Readme.md Changed copyright header on all files 2026年03月08日 07:44:31 +01:00
settings.gradle.kts Simple forms work 2025年12月10日 11:54:57 +01:00

kMultiPage - Server-Side framework for Kotlin

The main design goals of kMultiPage are:

  • Allow programming simple application directly with Kotlin+HTML, without any JavaScript knowledge
  • Use HTML directly to design pages, but make it easy to manipulate that HTML from Kotlin
  • Process mostly on the server, but without requiring session-management or stateful components
  • Hide the fact that the application is not a Single-Page-App from the user as much as possible

Start the complete documentation locally with the following command:

./gradlew :docs:run

Concept

Design your pages and components in pure HTML, e.g. my-page.html:

<html>
 <body>
 <h1 data-mpa-id="greeting"></h1>
 <button data-mpa-on-click="helloClicked">Hello!</button>
 </body>
</html>

You will use some special data- attributes to allow interaction between Kotlin and your HTML. Now, create a class to handle this page:

@HtmlPage("my-page.html")
class MyPage: MyPageController() {
 override fun build() {}
}

The base class MyPageController does not exist yet, so this class has compiler errors. But when you now run a full build of your project, the kMultiPage compiler will create the base class for you, and from now on, you can interact with the page. It even creates type-safe accessors for every element that has a data-mpa-id set, so you can access them from your page class

But there's still a compiler error: The compiler created an abstract method vor handling button clicks on the server, and you must implement that. Since the button has data-mpa-on-click="helloClicked", the handler method is called onHelloClicked:

@HtmlPage("my-page.html")
class MyPage: MyPageController() {
 override fun build() {}
 override fun onHelloClicked() {}
}

Now the class compiles, but it does not do anything yet... Let's add some functionality. We can use the greeting() accessor that the compiler created for us to access the heading from the HTML file:

@HtmlPage("my-page.html")
class MyPage: MyPageController() {
 override fun build() {
 greeting().updateText { "Hello kMultiPage" }
 }
 override fun onHelloClicked() {
 greeting().updateText { "You clicked the Hello-Button. Nice to meet you." } 
 }
}

License

 Copyright 2025-2026 David Tanzer (business@davidtanzer.net)
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

See LICENSE.txt