Skip to content

Commit 03f1c85

Browse files
author
ageery
committed
Added an example
1 parent 7aa7385 commit 03f1c85

File tree

8 files changed

+174
-0
lines changed

8 files changed

+174
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package dev.bombinating.bianmen.example
2+
3+
import dev.bombinating.bianmen.dsl.dsl
4+
import dev.bombinating.bianmen.dsl.tag.ExtendTag
5+
import dev.bombinating.bianmen.dsl.tag.ExtendTag.Companion.extend
6+
import org.apache.wicket.MarkupContainer
7+
import org.apache.wicket.markup.IMarkupCacheKeyProvider
8+
import org.apache.wicket.markup.IMarkupResourceStreamProvider
9+
import org.apache.wicket.util.resource.IResourceStream
10+
import org.apache.wicket.util.resource.StringResourceStream
11+
12+
abstract class BianmenDslExamplePage : BianmenExamplePage(), IMarkupResourceStreamProvider, IMarkupCacheKeyProvider {
13+
14+
15+
private var markup: String? = null
16+
17+
protected abstract val contents: ExtendTag.() -> Unit
18+
19+
override fun onInitialize() {
20+
val dsl = dsl()
21+
dsl.extend { contents.invoke(this) }
22+
val regionInfo = dsl.finalize()
23+
markup = regionInfo.markup
24+
super.onInitialize()
25+
@Suppress("SpreadOperator")
26+
add(*regionInfo.roots.toTypedArray())
27+
}
28+
29+
override fun getMarkupResourceStream(container: MarkupContainer, containerClass: Class<*>): IResourceStream =
30+
StringResourceStream(markup)
31+
32+
override fun getCacheKey(container: MarkupContainer, containerClass: Class<*>): String =
33+
containerClass.name
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package dev.bombinating.bianmen.example.helloworld
2+
3+
import dev.bombinating.bianmen.example.BianmenExampleWicketApp
4+
import org.apache.wicket.Page
5+
import kotlin.reflect.KClass
6+
7+
class HelloWorldApp : BianmenExampleWicketApp() {
8+
override val home: KClass<out Page> = HelloWorldPage::class
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
3+
<wicket:head>
4+
<title>Wicket Examples - helloworld</title>
5+
</wicket:head>
6+
<body>
7+
<wicket:extend>
8+
<span wicket:id="message" id="message">Message goes here</span>
9+
</wicket:extend>
10+
</body>
11+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dev.bombinating.bianmen.example.helloworld
2+
3+
import dev.bombinating.bianmen.ModelExt.unaryPlus
4+
import dev.bombinating.bianmen.example.BianmenExamplePage
5+
import dev.bombinating.bianmen.factory.LabelFactory.label
6+
7+
class HelloWorldPage : BianmenExamplePage() {
8+
init {
9+
add(label(id = "message", model = +"Hello World!"))
10+
}
11+
}

bianmen-example/src/main/kotlin/dev/bombinating/bianmen/example/logo-apachewicket-examples-white.svg

+92
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<configuration>
2+
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
3+
<encoder>
4+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
5+
</encoder>
6+
</appender>
7+
<root level="info">
8+
<appender-ref ref="CONSOLE"/>
9+
</root>
10+
</configuration>

gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ kotlinxHtmlVersion=0.7.3
1313
logbackVersion=1.2.3
1414
servlet31Version=3.1.0
1515
servlet4Version=4.0.1
16+
springBootVersion=2.5.3
1617
wicketVersion=9.4.0
1718

1819
# plugins
20+
dependencyManagementPluginVersion=1.0.11.RELEASE
1921
detektPluginVersion=1.18.0-RC2
2022
dokkaPluginVersion=1.5.0

settings.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
rootProject.name = "bianmen"
22

33
pluginManagement {
4+
val dependencyManagementPluginVersion: String by settings
45
val detektPluginVersion: String by settings
56
val dokkaPluginVersion: String by settings
67
val kotlinVersion: String by settings
8+
val springBootVersion: String by settings
79
plugins {
810
kotlin("jvm") version kotlinVersion
911
id("io.gitlab.arturbosch.detekt") version detektPluginVersion
12+
id("io.spring.dependency-management") version dependencyManagementPluginVersion
1013
id("org.jetbrains.dokka") version dokkaPluginVersion
14+
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
15+
id("org.springframework.boot") version springBootVersion
1116
}
1217
}
1318

0 commit comments

Comments
 (0)