I am beginner at Thymeleaf. All I know is the fact that "Thymeleaf is not Javascript, it is rendered on server." I am making mistakes all the time because I am usually trying to use that Thymeleaf a little like JavaScript.
HTML
<form th:action="@{/user/sqlCode}" method="post">
<button id="newDatabase"></button>
</form>
<textarea id="generatedSql" readonly></textarea>
Controller
@PostMapping(path = { "/user/sqlCode" })
public String createSchema(@RequestParam(???) String tmp) {
String finallyMyValue = tmp;
// STOP I want to have data from generatedSql in this moment (finallyMyValue)
// ...
}
@ MISSION @
1. Click button (id: newDatabase)
2. Get data from the textarea (id: generatedSql)
3. Send the value with that data to the controller
4. Be happy :)
@ MISSION @
I tried a lot of things but only using Javascript. Scenario is always the same, JavaScript is executed totally before Thymeleaf and finally I can't properly read that data... I tried that scenario:
- Click button (id: newDatabase)
- Get data from the textarea (id: generatedSql) using JavaScript
- Insert that data into variable
namein input tag using JavaScript - Send the variable
nameto the controller. - And here I always get NULL or error 404
Screenshot with my failed approach, which ended in a null at the breakpoint:
