diff --git a/core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/IViewContext.kt b/core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/IViewContext.kt index 928f591..7fd9eec 100644 --- a/core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/IViewContext.kt +++ b/core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/IViewContext.kt @@ -4,6 +4,8 @@ interface IViewContext { companion object { var componentBean: Any? = null var componentTemplate: String? = null + var jteTemplateEngine: Any? = null + var templateSuffx: String = "" fun getAttributes(context: IViewContext): Map { return context::class.java.declaredFields.map { field -> context::class.java.getDeclaredField(field.name).let { @@ -12,7 +14,11 @@ interface IViewContext { } }.toMap() } - } -} -class EmptyViewContext() : IViewContext \ No newline at end of file + fun getTemplate(context: IViewContext): String { + val componentName = context.javaClass.enclosingClass.simpleName.substringBefore("$$") + val componentPackage = context.javaClass.enclosingClass.`package`.name.replace(".", "/") + "/" + return "$componentPackage$componentName$templateSuffx" + } + } +} \ No newline at end of file diff --git a/examples/jte-example/build.gradle.kts b/examples/jte-example/build.gradle.kts index 48f2fc0..52599fa 100644 --- a/examples/jte-example/build.gradle.kts +++ b/examples/jte-example/build.gradle.kts @@ -7,25 +7,18 @@ plugins { kotlin("jvm") version "1.8.21" kotlin("plugin.spring") version "1.8.21" kotlin("kapt") version "1.8.21" - id("gg.jte.gradle") version("3.0.2") + // id("gg.jte.gradle") version("3.0.2") } group = "de.tschuehly" version = "0.0.1-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_17 -jte{ - generate() -} repositories { mavenCentral() maven("https://jitpack.io") } -//jte { -// sourceDirectory.set(Path.of("src/main/kotlin")) -// generate() -//} dependencies { // implementation("de.tschuehly:spring-view-component-jte:0.6.0") implementation("de.tschuehly:spring-view-component-jte:0.6.2-SNAPSHOT") @@ -54,17 +47,10 @@ tasks.withType { tasks.withType { useJUnitPlatform() } -//sourceSets { -// main { -// resources { -// srcDir("src/main/kotlin") -// exclude("**/*.kt") -// } -// } -// test { -// resources { -// srcDir("src/test/kotlin") -// exclude("**/*.kt") -// } -// } -//} +sourceSets{ + main{ + java{ + srcDir("build/generated-sources/jte") + } + } +} diff --git a/examples/jte-example/src/main/jte/TestViewComponent.jte b/examples/jte-example/src/main/jte/TestViewComponent.jte deleted file mode 100644 index 9b34ab1..0000000 --- a/examples/jte-example/src/main/jte/TestViewComponent.jte +++ /dev/null @@ -1,50 +0,0 @@ -@param de.tschuehly.jteviewcomponentdemo.web.action.ActionViewComponent.Person person -@param java.util.HashMap itemList -@param Integer counter - -
- -

ViewAction Get CountUp

- - -

${counter}

- - -

ViewAction Post AddItem

-
- - -
- - - - - - @for(var item: itemList.entrySet()) - - - - - @endfor -
ItemAction
- ${item.getValue()} - - -
- -

ViewAction Put/Patch Person Form

- -
- - - - - -
-
\ No newline at end of file diff --git a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.jte b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.jte index 1c0fef4..0c8109f 100644 --- a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.jte +++ b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.jte @@ -1,15 +1,17 @@ @param de.tschuehly.jteviewcomponentdemo.web.action.ActionViewComponent.Person person @param java.util.HashMap itemList @param Integer counter - -
TEST12 - + + + + + +

ViewAction Get CountUp

${counter}

-

ViewAction Post AddItem

@@ -36,15 +38,16 @@
-
\ No newline at end of file + + \ No newline at end of file diff --git a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.kt b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.kt index 09cb8ba..5805ca6 100644 --- a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.kt +++ b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.kt @@ -4,12 +4,13 @@ import de.tschuehly.jteviewcomponentdemo.core.ExampleService import de.tschuehly.spring.viewcomponent.core.IViewContext import de.tschuehly.spring.viewcomponent.core.action.* import de.tschuehly.spring.viewcomponent.core.component.ViewComponent +import de.tschuehly.spring.viewcomponent.jte.ViewContext @ViewComponent class ActionViewComponent( val exampleService: ExampleService ) { - data class ActionView(val itemList: MutableMap, val counter: Int, val person: Person) : IViewContext + data class ActionView(val itemList: MutableMap, val counter: Int, val person: Person) : ViewContext fun render() = ActionView(exampleService.itemList, counter, person) diff --git a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.jte b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.jte index 97cc7d4..3e63541 100644 --- a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.jte +++ b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.jte @@ -1,10 +1,12 @@ + \ No newline at end of file +

This is the IndexViewComponent

+ + +IndexViewComponent
+SimpleViewComponent
+LayoutViewComponent
+ActionViewComponent
+NestedActionViewComponent
+ + \ No newline at end of file diff --git a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.kt b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.kt index eaffc5d..715f8f2 100644 --- a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.kt +++ b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/index/IndexViewComponent.kt @@ -1,8 +1,9 @@ package de.tschuehly.jteviewcomponentdemo.web.index import de.tschuehly.spring.viewcomponent.core.component.ViewComponent +import de.tschuehly.spring.viewcomponent.jte.EmptyViewContext @ViewComponent class IndexViewComponent { - fun render() = de.tschuehly.spring.viewcomponent.core.EmptyViewContext() + fun render() = EmptyViewContext() } \ No newline at end of file diff --git a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/layout/LayoutViewComponent.jte b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/layout/LayoutViewComponent.jte index d30b716..8390bc8 100644 --- a/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/layout/LayoutViewComponent.jte +++ b/examples/jte-example/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/layout/LayoutViewComponent.jte @@ -1,5 +1,4 @@ -@import de.tschuehly.spring.viewcomponent.jte.ViewContext -@param ViewContext nestedViewComponent +@param de.tschuehly.spring.viewcomponent.jte.ViewContext nestedViewComponent