I call javascript, because this is the only way to archieve it. then i call my Java/kotlin method "splitIt" from javascript to fill my fields. then i want this result to be returned at the end.
but javascript is run at the end, so the result is empty
fun test01(): List<String> {
element.node.runWhenAttached { ui ->
println(1)
val x = ui.page.executeJavaScript(
"""setTimeout(
| function splitMyHTML () {
| ${'$'}0._editor.insertText(${'$'}0._editor.getSelection(true).index,"$CODEWORD");
| ${'$'}0.${'$'}server.splitIt();
| }
| ,0
|)""".trimMargin(), element
)
}
println(2)
return listOf(firstPart, secondPart)
}
@Suppress("unused") // this is used in javascript
@ClientCallable
fun splitIt() {
firstPart = "test1"
secondPart = "test2"
println(20)
}
output print is 1 2 20 and the list is empty
but i want it to be 1 20 2 and the list to be filled with "test1" and "test2"