I am writing a web app using HTML and Wicket.
In my HTML page, I have a small alert script and I need that the wicket will insert a value to the message of the alert. My code is:
HTML code:
<script>
function version(){
alert(<sub wicket:id="version">);
}
</script>
<img class="logo" src="images/logo.png" alt="" width="68" height="21" onclick="version()"/>
Java:
add(new Label("version","1.0.0");
But this is not working.
Wicket won’t process anything within
<script>. But you can add a JavaScript function via a header contribution in your page class (or any otherComponent).Wicket 1.5:
Wicket 6.0:
An alternative is to render a
Labelwhich outputs the function:And in your markup