If you are using Maven you can add the wicket-velocity dependency (otherwise you can download the jar from http://wicketstuff.org/maven/repository/org/apache/wicket/wicket-velocity/)
<dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket-velocity</artifactId> <version>${wicket.velocity.version}</version> </dependency>
Create a javascript file with a vm extension
example-script.vm
<script language="JavaScript"> function removeBlur(checked) { if(checked) { document.getElementById('${loginButtonId}').disabled = false; } else { document.getElementById('${loginButtonId}').disabled = true; } } </script>
In your web page constructor add a javascript velocity header contributor
MyWebPage.java
final Button loginButton = new Button("input-login-button", ...){...}; final Map<String, String> vars = new HashMap<String, String>(1); vars.put("loginButtonId", loginButton.getMarkupId()); return new VelocityHeaderContributor().add(new VelocityJavascriptContributor(MyWebPage.class, "path/to/example-script.vm", Model.valueOf(vars), "nameOfScript"));
The "loginButtonId" will be replaced by the generated wicket markup id in our a javascript file named "nameOfScript.js" for our MyWebPage.class