THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
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/)
Code Block |
---|
<dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket-velocity</artifactId> <version>${wicket.velocity.version}</version> </dependency> |
Create a javascript file with a vm extension
Code Block | ||
---|---|---|
| ||
<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
Code Block | ||
---|---|---|
| ||
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