-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
not working with jte yet, files need to be compiled
- Loading branch information
Thomas Schuehly
committed
Aug 12, 2023
1 parent
0406d96
commit a8ae285
Showing
29 changed files
with
332 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
rootProject.name = "jte-demo" | ||
rootProject.name = "jte-kotlin-example" | ||
|
||
//includeBuild("..\\..\\jte"){ | ||
// dependencySubstitution { | ||
// substitute(module("de.tschuehly:spring-view-component-jte")).using(project(":")) | ||
// } | ||
//} | ||
//includeBuild("..\\..\\core"){ | ||
// dependencySubstitution { | ||
// substitute(module("de.tschuehly:spring-view-component-core")).using(project(":")) | ||
// } | ||
//} | ||
includeBuild("..\\..\\jte"){ | ||
dependencySubstitution { | ||
substitute(module("de.tschuehly:spring-view-component-jte")).using(project(":")) | ||
} | ||
} | ||
includeBuild("..\\..\\core"){ | ||
dependencySubstitution { | ||
substitute(module("de.tschuehly:spring-view-component-core")).using(project(":")) | ||
} | ||
} |
19 changes: 18 additions & 1 deletion
19
examples/jte-demo/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/core/ExampleService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
package de.tschuehly.jteviewcomponentdemo.core | ||
|
||
import org.springframework.stereotype.Service | ||
import java.util.NoSuchElementException | ||
|
||
@Service | ||
class ExampleService { | ||
fun getSomeData() = "Hey everyone JTE Templating works!" | ||
var dataIndex = 0 | ||
val itemList = mutableMapOf<Int, String>() | ||
|
||
fun getHelloWorld(): String { | ||
return "Hello World" | ||
} | ||
|
||
fun addItemToList(item: String){ | ||
itemList[dataIndex] = item | ||
dataIndex += 1 | ||
} | ||
|
||
fun deleteItem(id: Int) { | ||
itemList.remove(id) ?: throw NoSuchElementException("No Element with Id: $id found") | ||
} | ||
|
||
|
||
} |
17 changes: 0 additions & 17 deletions
17
examples/jte-demo/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/Router.kt
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
examples/jte-demo/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/TestController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package de.tschuehly.jteviewcomponentdemo.web | ||
|
||
import de.tschuehly.jteviewcomponentdemo.web.action.ActionViewComponent | ||
import de.tschuehly.jteviewcomponentdemo.web.header.HeaderViewComponent | ||
import de.tschuehly.jteviewcomponentdemo.web.index.IndexViewComponent | ||
import de.tschuehly.jteviewcomponentdemo.web.layout.LayoutViewComponent | ||
import de.tschuehly.jteviewcomponentdemo.web.simple.SimpleViewComponent | ||
import org.springframework.stereotype.Controller | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.ModelAttribute | ||
|
||
@Controller | ||
class TestController( | ||
private val simpleViewComponent: SimpleViewComponent, | ||
private val indexViewComponent: IndexViewComponent, | ||
private val layoutViewComponent: LayoutViewComponent, | ||
private val headerViewComponent: HeaderViewComponent, | ||
private val actionViewComponent: ActionViewComponent | ||
) { | ||
|
||
@GetMapping("/") | ||
fun indexComponent() = indexViewComponent.render() | ||
|
||
@GetMapping("/action") | ||
fun actionComponent() = actionViewComponent.render() | ||
|
||
@GetMapping("/nested-action") | ||
fun nestedActionComponent() = layoutViewComponent.render(actionViewComponent.render()) | ||
|
||
@GetMapping("/simple") | ||
fun simpleComponent() = simpleViewComponent.render() | ||
|
||
|
||
@GetMapping("/layout") | ||
fun layoutComponent() = layoutViewComponent.render(simpleViewComponent.render()) | ||
|
||
@GetMapping("/header") | ||
fun header(): String { | ||
return "test" | ||
} | ||
|
||
@ModelAttribute("header") | ||
fun headerComponent() = headerViewComponent.render("TestTitle") | ||
} |
50 changes: 50 additions & 0 deletions
50
...demo/src/main/kotlin/de/tschuehly/jteviewcomponentdemo/web/action/ActionViewComponent.jte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@param de.tschuehly.spring.viewcomponent.jte.application.web.action.ActionViewComponent.Person person | ||
@param java.util.HashMap<Integer,String> itemList | ||
@param Integer counter | ||
|
||
<div> | ||
<script defer src="/webjars/htmx.org/dist/htmx.min.js"></script> | ||
<h2>ViewAction Get CountUp</h2> | ||
|
||
<button view:action="countUp">Default ViewAction [GET]</button> | ||
<h3>${counter}</h3> | ||
|
||
|
||
<h2>ViewAction Post AddItem</h2> | ||
<form view:action="addItem"> | ||
<input type="text" name="item"> | ||
<button type="submit">Save Item</button> | ||
</form> | ||
<table> | ||
<tr> | ||
<th>Item</th> | ||
<th>Action</th> | ||
</tr> | ||
@for(var item: itemList.entrySet()) | ||
<tr> | ||
<td> | ||
<span>${item.getValue()}</span> | ||
</td> | ||
<td> | ||
<button view:action="deleteItem?id=${item.getKey()}">Delete Item ${item.getKey()}</button> | ||
</td> | ||
</tr> | ||
@endfor | ||
</table> | ||
|
||
<h2>ViewAction Put/Patch Person Form</h2> | ||
|
||
<form style="display: inline-grid; gap: 0.5rem"> | ||
<label> | ||
Name <input type="text" name="name" value="${person.getName()}"> | ||
</label> | ||
<label> | ||
Age: <input type="number" name="age" value="${person.getAge()}"> | ||
</label> | ||
<label> | ||
Location: <input type="text" name="location" value="${person.getLocation()}"> | ||
</label> | ||
<button type="submit" view:action="savePersonPut">Save Changes using Put</button> | ||
<button type="submit" view:action="savePersonPatch">Save Changes using Patch</button> | ||
</form> | ||
</div> |
Oops, something went wrong.